Each validator can only validate one value. It is one important feature
of validators: isolation.
If you want to validate 2 fields, like a password and a password_bis
fields, you can use the _post_validator feature of a validator schema:
$this->validatorSchema = new sfValidatorSchema(array(
'password' => ...,
'password_bis' => ...,
// ...
'_post_validator' => new sfValidatorSchemaCompare('password', '==',
'password_bis'),
));
The _post_validator receives the full array of cleaned values.
You can also use the _pre_validator, but it receives the full array of
tainted values, instead of cleaned values.
Fabien
--
Fabien Potencier
Sensio CEO - symfony lead developer
http://www.sensiolabs.com/
http://www.symfony-project.com/
Sensio Labs
Tél: +33 1 40 99 80 80
Ian P. Christian wrote:
> Hi all,
>
> I'm working with the new sf1.1 form/validation stuff, and I've just
> encountered a problem I'm struggling to figure out.
>
> How do you handle things like comparing 2 fields, or accessing other
> fields of a form from within the validator.
> You could directly access the request params, but doing so would require
> you to pass the name of the field to be compared against (which could be
> in the format of 'something[likethis]' if you're using
> sfForm::setNameFormat).
>
> I feel I'm missing the obvious, any ideas?
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---