Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-14-2008, 02:32 AM
kmg kmg is offline
Junior Member
 
Join Date: Mar 2008
Posts: 9
Default Zend_Validate_Identical not working.

I can't get Zend_Validate_Identical to work. It just always says "No token was provided to match against", no matter what.

PHP Code:

        $form
->addElement('text''first'
            array(
                
'required'    => true,
                
'label'        => 'First Name',
                
'validators'    => array(
                    
'alnum',
                    array(
'StringLength'503),
                    array(
'regex'false'/^[a-zA-Z]/i'),
                    array(
'Identical''test')
                    ),
                )
            ); 
So what's the deal?

Also, I need to compare one form field to another form field (password to confirm password), and the easiest way I could think while following the validation model was to write a custom validator, something like Zend_Validate_IdenticalToField that would just take in a form element, and call it's getValue method for comparison. Is there some better way this could be implemented within the Zend_Form / Zend_Validate pattern? Also, what about a UniqueInModelField validator that checks against a model for any existing entries that would conflict, like for a unique email address? These are probably outside of the scope of Zend_Validate by quite a bit though. What do you guys think?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-05-2008, 04:40 PM
Junior Member
 
Join Date: May 2008
Posts: 4
Default

you should use this:
array('Identical', $variable)

if you set 'test', the validator compares text from your input field with the 'test' word

if you have input field named 'test', you should write something like that:

array('Identical', $this->getRequest()->getParam('test'))

in other words:
Code:
//password entered in the form
$password = $this->getRequest()->getParam('password'); 

//repeat password field in your form
$form->addElement('password', 'repeat_password', 
        array(
                //...
                'validators'    => array(
                 //...
                    array('Identical', $password)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:27 AM.