What happens in your configuration is that you say:
$password is my token and I want to validate it against the form element.
But the form element is an object... so this can not work as these two are
not identical.
What you can do in this case is to extract the identical validator and use
it standalone.
$val = new Zend_Validate_Identical($password);
if (!$val->isValid($repassword)) {
$form->setError('Nope');
}
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "whisher" <whisher@mp4.it>
To: <fw-mvc@lists.zend.com>
Sent: Tuesday, September 08, 2009 10:14 AM
Subject: Re: [fw-mvc] Validation identical in the form
Thanks for the replay.
I'm waiting to get an error if I type something
different between password and repassword.
What happens the code don't catch the error :(
Bye.
Matthew Weier O'Phinney-3 wrote:
>
> -- whisher <whisher@mp4.it> wrote
> (on Monday, 07 September 2009, 08:32 AM -0700):
>> Hi. What's wrong in this code
>
> What are you expecting to happen, and what is actually happening?
>
>> $request = Zend_Controller_Front::getInstance()->getRequest();
>> $password = $request->getParam('password', '');
>> $this->addElement('password', 'password', array(
>> 'required' => true,
>> 'maxlength' => 15,
>> 'title' => 'Sono ammessi solamente caratteri alfanumerici e
>> @,#,*',
>> 'label' => 'form_User_Register_Label_Password',
>> 'filters' => array('StringTrim'),
>> 'validators' => array(
>> array('stringLength',true, array(2, 25)),
>> array('regex', false,
>> array('#^[^\.<>{};:"£$%\/^&()_\+\-=\]\[]+#')))
>> ));
>>
>> // Re-Password
>> $repassword = $request->getParam('repassword', '');
>> $this->addElement('password', 'repassword', array(
>> 'required' => true,
>> 'maxlength' => 15,
>> 'title' => 'Sono ammessi solamente caratteri alfanumerici e
>> @,#,*',
>> 'label' => 'form_User_Register_Label_RePassword',
>> 'filters' => array('StringTrim'),
>> 'validators' => array(
>> array('stringLength',true, array(2, 25)),
>> array('regex', true,
>> array('#^[^\.<>{};:"£$%\/^&()_\+\-=\]\[]+#')),
>> array('identical',false, array($password ,$repassword))
>> )
>> ));
>
> --
> Matthew Weier O'Phinney
> Project Lead | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>
--
View this message in context:
http://www.nabble.com/Validation-identical-in-the-form-tp25332316p25341704.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论