sfValidatorPropelUnique as post validator? When did that changed? Here's some live code from one of my forms:
$this->setValidator('health_care_institution_book_number', new sfValidatorAnd(array( new sfValidatorRegex(array('required' => false, 'pattern' => '/^[0-9]{2}[-]([0-9]{5})?$/'), array('invalid' => 'Book number format is invalid (xx-xxxxx)')), new sfValidatorPropelChoice(array('model' => 'HealthCareInstitution', 'column' => 'book_number', 'required' => false), array('invalid' => 'health care intitution does not exist.')), ), array('halt_on_error' => true, 'required' => false))); Feel free to use it as a snipet. Cheers, Alan On Sat, Mar 21, 2009 at 1:25 AM, Sid Bachtiar <sid.bacht...@gmail.com>wrote: > > > This may seem minor, but it's wasting resources and > > driving me nuts. > > Yep, sfValidatorAnd has driven many people mad, nut, crazy, and > generally annoyed. > > Use sfValidatorAndWithBreak for more proper operator 'And' behaviour > from http://forum.symfony-project.org/index.php/m/70930/ > > On Sat, Mar 21, 2009 at 1:17 PM, Benjamin <agtle...@gmail.com> wrote: > > > > I'm trying to do something very simple. All I want to do is validate > > a field. If the field is valid I want to verify that it is (unique), > > ie not already in the database. > > > > I have tried many different combinations of validators, but symfony > > insists on running a database query to check if it exists even if it > > is not valid. This may seem minor, but it's wasting resources and > > driving me nuts. > > > > Here is the method I have tried that I was sure would work, but I get > > the error saying that sfValidatorPropelUnique must be used as a post > > validator... even though that is where I put it. > > > > public static function email() { > > return new sfValidatorAnd( > > array( > > new sfValidatorAnd( > > array( > > new sfValidatorString( > > array( > > 'min_length' => sfConfig::get > > ('sf_validation_email_min_len'), > > 'max_length' => sfConfig::get > > ('sf_validation_email_max_len'), > > 'trim' => true, > > ), > > array( > > 'min_length' => 'Email is too short > > (%min_length% characters minimum)', > > 'max_length' => 'Email is too long > > (%max_length% characters maximum)', > > ) > > ), > > new sfValidatorEmail( > > array( > > ), > > array( > > 'invalid' => 'Your email address is > > invalid', > > ) > > ), > > ) > > ), > > new sfValidatorPropelUnique( > > array( > > 'model' => 'User', > > 'column' => 'email', > > ), > > array( > > 'invalid' => 'This email address is in use > > by another account', > > ) > > ) > > > > ), > > array( > > 'halt_on_error' => true, > > 'required' => true, > > ), > > array( > > 'required' => 'Email address is required', > > ) > > ); > > } > > > > In my form class: > > > > protected function setPostValidators() { > > $this->validatorSchema->setPostValidator( > > new sfValidatorAnd( > > array( > > asValidatorsCollection::userNameUnique(), > > asValidatorsCollection::emailUnique(), > > ) > > ) > > ); > > } > > > > Am I approaching this wrong? I'm thinking this should be very simple. > > > > > > > > > -- > Blue Horn Ltd - System Development > http://bluehorn.co.nz > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---