1

Want to show a custom message in form's error list, if the two fields did not match. the from is as follows, 'old_password' =>'Old Password*', 'new_password' =>'New Password*', 'confirm_password' =>'Confirm Password*', I want that the old password should match the value from the database, the value in new password and confirm password should also match. please help me.

1 Answer 1

3

In Symfony 1.1 and later, to compare if the two form fields match you need to set up a post validator, like:

$this->validatorSchema->setPostValidator(
  new sfValidatorSchemaCompare(
    'new_password', 
    sfValidatorSchemaCompare::EQUAL, 
    'confirm_password',
    array(),
    array('invalid' => 'Your custom error message here!!')
  )
);

Try reading Symfony forms in Action, it should solve most of your problems about form creation and validation within the Symfony framework

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.