Today I was working with a form where we had the following code:

    $this->widgetSchema["email"] = new sfWidgetFormInputText();
    $this->validatorSchema["email"] = new sfValidatorAnd(
    array(
        new sfValidatorEmail( array("required" => true) ),
        new sfValidatorDoctrineUnique(
            array("throw_global_error" => true, "model" =>
"sfGuardUser", "column" => "username"),
            array("invalid" => "Sorry! A user with that email address
already exists.")
        ),
    ));

      $this->validatorSchema->setPostValidator(
        new sfValidatorAnd( array(
                            new sfValidatorCallback( array('callback'
=> array($this, 'validateBirthday'))
),
                            new sfValidatorSchemaCompare('password',
'==', 'confirm_password'),
                            new sfValidatorSchemaCompare('email',
'==', 'confirm_email')
        ))
      );


So you would think that when the email validator fails because there
is an email already in the DB it would
give us a Sorry! A user... error message.  However we kept getting
that message followed by an additional
message 'Invalid'.

After looking into this a bit more and how the post validators work it
seems that since the email
sfValidatorAnd throws an error instead of returning a clean value it
causes the post validator to not get a value, thus the email doesn't
match the confirm_email field.

I'm not sure what would be a good way to fix this as the validator
could manipulate the values, however in this case the post validator
is not very helpful, and causes confusion/an improper validation error
to occur.  You could in this case use a callback and say if the value
is empty to not bother checking if it matches the email(as it would
already have a validation error on being a required field).

Just wanted to see if anyone else here has a different/better
solution.

Daum

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" 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-devs?hl=en

Reply via email to