You should add the propel unique validator to your form, since the unique violation error while saving is too late - you need to get the error while validating the form itself, not the propel object behind the form. You get the invalid error you specified when the data submitted by the user is not a string - kinda rarely in php.
On Mon, Oct 19, 2009 at 09:36, Adrien Mogenet <[email protected]> wrote: > > Actually, I'm not using sfValidatorPropelUnique. My "login" field is > checked by a sfStringValidator, but the "unique" constraint is checked > by Propel anyway, and the "unique" error message is displayed. (unique > constraint has been set in schema.yml). > > I would like to be able to write sthg like : > > $this->validatorSchema['login'] = new sfValidatorString(array > ('required' => false), array('invalid' => 'Login already exists')); > > -- > Adrien > > On 18 oct, 23:34, Gábor Fási <[email protected]> wrote: >> http://trac.symfony-project.org/browser/branches/1.2/lib/plugins/sfPr... >> >> sfValidatorPropelUnique throws an "invalid" error, customize that in >> your form, in the second parameter of the constructor. >> >> On Sun, Oct 18, 2009 at 23:26, Adrien Mogenet <[email protected]> >> wrote: >> >> > Hi, >> >> > My field "login" has been set as unique. >> >> > So when I try to register as an existing user, Propel is warning me >> > correctly with an error message (an object with the same _ _ _ _ >> > already exists), but I would like to use a custom message. >> >> > How can I do that ? >> >> > Btw, I created a custom UniqueValidator, with a custom error message, >> > but when I use this custom UniqueValidator, my forms displays both >> > errors : my custom message AND the propel error message. >> >> > Ho can I avoid this behaviour ? >> >> > Regards, >> >> > -- >> > Adrien > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" 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-users?hl=en -~----------~----~----~----~------~----~------~--~---
