Password Confirmation in zend framework

后端 未结 5 639
萌比男神i
萌比男神i 2021-01-03 04:32

I add this class to library/My/Validate/PasswordConfirmation.php



        
5条回答
  •  误落风尘
    2021-01-03 04:54

    There is a bettter way to do that. In your form put the identical validator on the confirmation passoword field, and then just overwrite $form->isValid() method to set the value to be validated:

    public function __construct($options = NULL)
    {
       // ...
       $confirm->addValidator('Identical');
       // ...
    }
    public function isValid($data)
    {
        $confirm = $this->getElement('confirm_password');
        $confirm->getValidator('Identical')->setToken($data['password']);
        return parent::isValid($data);
    }
    

提交回复
热议问题