Fabien POTENCIER wrote:
> 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'),
> ));
>

Using this _post_validator - how is it possible to fire a validation 
failure for a specific field?

For example, when validating a password  is equal to password_compare, 
you'd want the error to show for 'password'.

I can for exmaple do this:

       $this->setValidatorSchema(
         new sfValidatorSchema(array(
           'username' => new sfValidatorString(),
           'password' => new sfValidatorString(),
           '_post_validator' => new myValidatorLogin(array('username' => 
'username', 'password' => 'password')),
         )));


....

   class myValidatorLogin extends sfValidator
   {
     public function configure($options = array(), $messages = array())
     {
       $this->addOption('username');
       $this->addOption('password');
     }

     public function doClean($value)
     {
       throw new sfValidatorError($this, 'Invalid username/password 
combination');
     }
   }


....

This shows as a general form error, but... what about when I want it to 
appear for a specific field?


-- 

Ian P. Christian ~ http://pookey.co.uk

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to