I have made a form for client registration, and I can’t make this postvalidators working.
//POST-VALIDATORS
$this->validatorSchema->setPostValidator(
new sfValidatorSchemaCompare(
'email', sfValidatorSchemaCompare::EQUAL, 'reemail',
array(),
array('invalid' => "Les adresses mails sont différentes !")
));
$this->validatorSchema->setPostValidator(
new sfValidatorSchemaCompare(
'password', sfValidatorSchemaCompare::EQUAL, 'repassword',
array(),
array('invalid' => "Les mots de passe sont différents !")
));
$this->validatorSchema->setPostValidator(new sfValidatorCallback(
array('callback' => array($this,'checkEmailAvailability'))
));
The weird thing is : only the sfValidatorCallback which use my custum function is working. When I submit my form with two different values, for exemple on the password and repassword fields, the form is correctly submitted and no error is raised.
Someone got an idea ?
Thanks in advance for the help.
I know exaclty your problem, each time you use setPostValidator you are overriding the others (thats wy always the last one worked), my advise would be to use mergePostValidators, code should look like this:
The mergePostValidator function concats each post validator with a logical “And” operand. So your post validator will return true if all of them are true.