|
|||
|
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:
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? |
|
|||
|
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)
|
|
|||
|
I solved it this way.
NOTE: - $context['wachtwoordA] is the name of the first passwordfield - $value is the value of the field which it is validating. - This is the isValid method from my own custom validator Code:
public function isValid($value, $context = null)
{
$value = (string) $value;
$this->_setValue($value);
if (is_array($context))
{
if (isset($context['wachtwoordA'])
&& ($value == $context['wachtwoordA']))
{
return true;
}
}
elseif (is_string($context) && ($value == $context))
{
return true;
}
$this->_error(self::NOT_MATCH);
return false;
}
|
|
|||
|
Greetings All,
I have created a more generic solution to this problem, allowing one to validate any field against any other field (e.g. make sure passwords match, emails match, value match captcha challenge, etc.). I couldn't seem to get the markup on this page to look right, so I've provided the code at the this link along with example usage. Enjoy! Sean P. O. MacCath-Moran Welcome | emanaton dot com |
|
|||
|
Hi,
I ran into the same problems. I tried to fix it like this PHP Code:
This seems to work just fine, at least for me. |
|
|||
|
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|