I’m using sfGuard plugin for Doctrine.
I want to override the default error message for unique username.
What I currently get is: “An object with the same “username” already exist.”.
So, I tried doing this:
$this->validatorSchema->getPostValidator('username')->setMessage('invalid', 'The username is already taken.');
which didn’t work.
Then I also tried
$this->mergePostValidator(
new sfValidatorDoctrineUnique(
array(
'model' => 'sfGuardUser',
'column' => array('username'),
'throw_global_error' => false
),
array(
'invalid' => 'The username is already taken.'
)
)
);
and now I’m getting 2 errors outputed: mine and the default one.
How can i fix the second portion of the code in order to get only 1 message outputed?
Add this method to
BaseDoctrineForm. Then, in your configure method (or anywhere esle) you can do:The method: