ITYM 'allowEmpty' => true, but yes that works, thanks!

On Feb 9, 10:35 am, Jeremy Burns | Class Outfit
<[email protected]> wrote:
> Required just indicates whether the field must be present when validating. So 
> if it's empty, it's not there, and as it's not required the validation 
> passes. Try setting 'allowEmpty' => false instead.
>
> Jeremy Burns
> Class Outfit
>
> http://www.classoutfit.com
>
> On 9 Feb 2012, at 15:22:25, Benno wrote:
>
>
>
>
>
>
>
> > 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 
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help 
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this group 
> > athttp://groups.google.com/group/cake-php

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to