|Changing default message for a specific validator in a merged series of validators [message #103361]
||Sat, 31 July 2010 20:21
Registered: July 2010
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:
'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?