Thanks for the reply. So in your code, this validation is associated with password, so wherever I decide to render validation errors for password, this would be shown there. What if I wanted to render this validation error separately from other field validations? Ultimately, I'd like validation errors for a particular field to be along side the field in question, I'd like more general validation errors such as password mismatch or data uniqueness to be shown in a separate area of the form. Is there a way to render an error for a field, *for* a particular message?
Thanks again. On Sep 14, 8:03 pm, Miles J <mileswjohn...@gmail.com> wrote: > Add this to your AppModel. > > /** > * Validates two inputs against each other > * @param array $data > * @param string $confirmField > * @return boolean > */ > function isMatch($data, $confirmField) { > $data = array_values($data); > $var1 = $data[0]; > $var2 = (isset($this->data[$this->name][$confirmField])) ? $this->data > [$this->name][$confirmField] : ''; > > return ($var1 === $var2); > > } > > Then add the validation rule to your Model. > > 'password' => array( > 'isMatch' => array( > 'rule' => array('isMatch', 'confirmPassword'), > 'message' => 'Your confirmed password does not match' > ) > ) > > Hope that helps. > > On Sep 14, 6:26 pm, mikeottinger <mikeottin...@gmail.com> wrote: > > > Hi All, > > > My apologies if this has been discussed before, giving a search of > > the forum didn't reveal anything. I'd think this would be easy. I'm > > attempting the classic validation of two password fields to ensure > > they're identical. I could get this to work by associating a custom > > validation method with the password or password2 field. But this > > doesn't seem the appropriate way to go about doing this. I'd like to > > handle the validation as a general error to the form in total not a > > specific, field. Form errors really only deal with a specific field. > > > If this isn't possible, can I create the notion of a 'virtual' field > > that I can associate this validation with? > > > Any advice would be greatly appreciated. > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---