I never used the identical validator before but my first thought was that it
should be something like this:
$password = self::createElement('text', 'newpassword');
->setRequired(true)
->setLabel('Password');
$password1 = self::createElement('text', 'newpassword1');
->addValidator('identical', true, array('newpassword')
->setRequired(true)
->setLabel('Check password');
In my opinion the third paramter should be the form-element-name. But if you
check the code of the validator, the third parameter is the value you check.
That's why you have to post 2 times. First you post your newpassword field,
and pass it again to the form. Then the third parameter of the validator can
be set.
What you could do is this:
$password = self::createElement('text', 'newpassword');
$password->setRequired(false)
->setLabel('password');
$password1 = self::createElement('text', 'newpassword1');
$password1->addValidator('identical')
->setRequired(true)
->setLabel('check password');
and just before your isValid:
$validator = $form->getElement('newpassword1')->getValidator('identical');
$validator->setToken($this->_request->getPost('newpassword'));
-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context:
http://www.nabble.com/Zend_Form---Identical-Validator-and-comparing-form-fields-tp21295103p21296119.html
Sent from the Zend Framework mailing list archive at Nabble.com.