Re: [symfony-users] Re: sfValidatorDoctrineUnique doesn't work when only defined in BaseForm?
Can you put somewhere code of those classes? Alan On Mon, Apr 12, 2010 at 5:00 AM, godbout guillaume.lecler...@gmail.comwrote: Hi Alan, Obviously I wasn't really awake that day... The form is SubscriberForm (not NewsletterForm) and it extends BaseSubscriberForm. I had to copy/paste the code from BaseSubscriberForm to SubscriberForm to make it work. On Apr 11, 8:37 pm, Alan Bem alan@gmail.com wrote: Aren't you talking about two different Forms? It seems that first post-validator comes from (Base)SubscriberForm, but you complaint about NewsletterForm. Is there inheritance relationship beetween them? Cheers On Sat, Apr 10, 2010 at 5:05 PM, godbout guillaume.lecler...@gmail.com wrote: Hi there! I have a very simple thing to do: allowing visitors to register their email for a newsletter. The email field is defined as unique in the db, and Doctrine created me the BaseForm with the following code:... [code]$this-validatorSchema-setPostValidator( new sfValidatorDoctrineUnique(array('model' = 'Subscriber', 'column' = array('email'))) ); [/code] ...which is exactly what I want. But it didn't work until I copy/ pasted exactly the same code in my NewsletterForm. Any explanation for that? My NewsletterForm doesn't contain much, but it redefined the email field validator from ValidatorString to ValidatorEmail. Would that cause the problem? I'm still surprised. Let me know if you have an idea ;-) Guill -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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.comsymfony-users%2bunsubscr...@googlegroups.com symfony-users%2bunsubscr...@goog legroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe, reply using remove me as the subject. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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.comsymfony-users%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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
[symfony-users] Re: sfValidatorDoctrineUnique doesn't work when only defined in BaseForm?
Sure. // BaseSubscriberForm.class.php -- abstract class BaseSubscriberForm extends BaseFormDoctrine { public function setup() { $this-setWidgets(array( 'id' = new sfWidgetFormInputHidden(), 'email' = new sfWidgetFormInputText(), 'deleted_at' = new sfWidgetFormDateTime(), 'created_at' = new sfWidgetFormDateTime(), 'updated_at' = new sfWidgetFormDateTime(), )); $this-setValidators(array( 'id' = new sfValidatorDoctrineChoice(array('model' = $this-getModelName(), 'column' = 'id', 'required' = false)), 'email' = new sfValidatorString(array('max_length' = 255)), 'deleted_at' = new sfValidatorDateTime(array('required' = false)), 'created_at' = new sfValidatorDateTime(), 'updated_at' = new sfValidatorDateTime(), )); $this-validatorSchema-setPostValidator( new sfValidatorDoctrineUnique(array('model' = 'Subscriber', 'column' = array('email'))) ); $this-widgetSchema-setNameFormat('subscriber[%s]'); $this-errorSchema = new sfValidatorErrorSchema($this- validatorSchema); $this-setupInheritance(); parent::setup(); } public function getModelName() { return 'Subscriber'; } } // SubscriberForm.class.php -- class SubscriberForm extends BaseSubscriberForm { public function configure() { unset($this['id'], $this['deleted_at'], $this['created_at'], $this['updated_at']); $this-widgetSchema-setLabel('email', 'Your email'); $this-setValidators(array( 'email' = new sfValidatorEmail(array('trim' = true), array( 'required' = 'Forgot to type your email? Try again! ', 'invalid' = 'Oups, this doesn\'t look like a valid email. Try again!' )), )); $this-validatorSchema-setPostValidator( new sfValidatorDoctrineUnique(array('model' = 'Subscriber', 'column' = array('email'))) ); $this-widgetSchema-setFormFormatterName('list'); } } As you can see the PostValidator is the same. If I don't put it in SubscriberForm it doesn't work. On Apr 12, 6:52 pm, Alan Bem alan@gmail.com wrote: Can you put somewhere code of those classes? Alan On Mon, Apr 12, 2010 at 5:00 AM, godbout guillaume.lecler...@gmail.comwrote: Hi Alan, Obviously I wasn't really awake that day... The form is SubscriberForm (not NewsletterForm) and it extends BaseSubscriberForm. I had to copy/paste the code from BaseSubscriberForm to SubscriberForm to make it work. On Apr 11, 8:37 pm, Alan Bem alan@gmail.com wrote: Aren't you talking about two different Forms? It seems that first post-validator comes from (Base)SubscriberForm, but you complaint about NewsletterForm. Is there inheritance relationship beetween them? Cheers On Sat, Apr 10, 2010 at 5:05 PM, godbout guillaume.lecler...@gmail.com wrote: Hi there! I have a very simple thing to do: allowing visitors to register their email for a newsletter. The email field is defined as unique in the db, and Doctrine created me the BaseForm with the following code:... [code]$this-validatorSchema-setPostValidator( new sfValidatorDoctrineUnique(array('model' = 'Subscriber', 'column' = array('email'))) ); [/code] ...which is exactly what I want. But it didn't work until I copy/ pasted exactly the same code in my NewsletterForm. Any explanation for that? My NewsletterForm doesn't contain much, but it redefined the email field validator from ValidatorString to ValidatorEmail. Would that cause the problem? I'm still surprised. Let me know if you have an idea ;-) Guill -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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.comsymfony-users%2bunsubscr...@goog legroups.com symfony-users%2bunsubscr...@goog legroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe, reply using remove me as the subject. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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.comsymfony-users%2bunsubscr...@goog legroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com
[symfony-users] Re: sfValidatorDoctrineUnique doesn't work when only defined in BaseForm?
Hi Alan, Obviously I wasn't really awake that day... The form is SubscriberForm (not NewsletterForm) and it extends BaseSubscriberForm. I had to copy/paste the code from BaseSubscriberForm to SubscriberForm to make it work. On Apr 11, 8:37 pm, Alan Bem alan@gmail.com wrote: Aren't you talking about two different Forms? It seems that first post-validator comes from (Base)SubscriberForm, but you complaint about NewsletterForm. Is there inheritance relationship beetween them? Cheers On Sat, Apr 10, 2010 at 5:05 PM, godbout guillaume.lecler...@gmail.comwrote: Hi there! I have a very simple thing to do: allowing visitors to register their email for a newsletter. The email field is defined as unique in the db, and Doctrine created me the BaseForm with the following code:... [code]$this-validatorSchema-setPostValidator( new sfValidatorDoctrineUnique(array('model' = 'Subscriber', 'column' = array('email'))) ); [/code] ...which is exactly what I want. But it didn't work until I copy/ pasted exactly the same code in my NewsletterForm. Any explanation for that? My NewsletterForm doesn't contain much, but it redefined the email field validator from ValidatorString to ValidatorEmail. Would that cause the problem? I'm still surprised. Let me know if you have an idea ;-) Guill -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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.comsymfony-users%2bunsubscr...@goog legroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe, reply using remove me as the subject. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com 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