Thursday, February 9, 2012

Email validation Q

Hi all,

I've searched the archives and open tickets, but perhaps I've missed
something obvious...

I'm using Cake 2.0.5, and I've got a model with the following:

public $validate = array(
'notify_on_provision' => array(
'rule' => 'email',
'required' => false
),
[various other rules that work fine]
);

If I submit a form generated in the corresponding view, the field
fails to validate with "This field cannot be left blank". The problem
under the hood appears to be that in Cake/Utility/Validation::email
the regex comparison fails (fair enough, the entry is blank), which in
turn sets $valid = false in Cake/Model::invalidFields, which causes
the error message.

So... should I be doing something else to allow an email address to be
optional? Or should I file a bug? (If I change the rule to be
something like '/.*/' it works as expected, but then obviously I lose
the email syntax check.)

Thanks!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate