This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Changing default message for a specific validator in a merged series of validators
Changing default message for a specific validator in a merged series of validators [message #103361] Sat, 31 July 2010 20:21
milind42  is currently offline milind42
Messages: 6
Registered: July 2010
Junior Member
I am trying to implement a user registration form in Symfony, with the help of the sfDoctrineGuardPlugin.

I created a UserRegisterForm that extends sfDoctrineGuardPlugin, and I'm unsetting all fields except first_name, last_name, email_address, password, password_confirm (added by me).

The form has a couple of post validators configured:
  • sfValidatorDoctrineUnique (configured by BasesfGuardUserForm): to check for uniqueness of email_address
  • sfValidatorSchemaCompare (configured by me, within UserRegisterForm): to check if password and password_confirm are the same

I merged the second one using mergePostValidator().

Now the problem is this - I've configured an 'invalid' message for the password compare validator, like this:
$this->mergePostValidator(new sfValidatorSchemaCompare(
       'password', '==', 'password_confirm',
       array('invalid' => "The two passwords don't match.")));  

However, the default 'invalid' message for sfValidatorDoctrineUnique is 'An object with the same "email_address" already exist.' I want to change it, but I can't figure out how. I'm guessing this won't work:
$this->getPostValidator()->setMessage('invalid', 'This email address already exists.");

because won't an invalid key already exist? And I don't want to setPostValidator() all over again, because there are other validators configured in the base form. So I'm not sure how I should proceed. Any ideas?

Previous Topic:Test names in exported XML test results
Next Topic:filter for front_dev
Goto Forum:

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software