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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to