I've chaged the code in my Model in this way:
var $validate=array('reminder'=>array( 'required'=>false,
'allowEmpty'=>true,
'rule'=>array('date', 'format'=>'ymd'),
'rule'=>array('between', 10, 10),
'rule'=>array('validReminderDate')));
Now thigs seems to work but I cannot set different
valdiaton_error_messages - for any validation rule i receive "This
field cannot be left blank" when the field is invalid. Here is a part
of my view:
print $form->input('Comment.reminder', array('type'=>'text',
'length'=>10, 'maxlength'=>10,
'error'=>array('date'=>'Invalid date format',
'length'=>'Length is 10 symbols', 'valid_date'=>'Date can not be in
the past')));
On Oct 29, 4:01 pm, francky06l <[EMAIL PROTECTED]> wrote:
> Sorry did not read the complete code, but I have something like this
> that works :
>
> 'email' =>
> array(array('allowEmpty' => true,
> 'rule' =>
> 'checkEmails'))
>
> On Oct 29, 2:54 pm, senser <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > After upgrading to CakePHP 1.2.0.5875 from 1.2.0.5427 I can't set
> > validation for form fields that are NO obligatory. Untill now I used
> > this code ana everything seemed to work fine:
>
> > /********MODEL SNIPPET************/
> > var
> > $validate=array('reminder'=>array(
> > 'required'=>array('rule'=>array('required'=>false)),
> >
> > 'allow_empty'=>array('rule'=>array('allowEmpty'=>true)),
> >
> > 'date'=>array('rule'=>array('date', 'format'=>'ymd')),
> >
> > 'length'=>array('rule'=>array('between', 10, 10)),
> >
> > 'valid_date'=>array('rule'=>array('validReminderDate')));
> > /********************************/
> > The idea was if user doesn't enter reminder date and validation of
> > this field passes, but if he enters some values field must be
> > validated as a valid date in the future (this is the custom validation
> > rule called validReminderDate). This worked fine for me with previous
> > version, but now if the reminder_field is left blank the form doesn't
> > validate.
>
> > I have read all the topics in GoogleGroups relevant to this bu I
> > didn't find a
> > solution:http://groups.google.com/group/cake-php/search?group=cake-php&q=allow......
>
> > The theme is discussed many times but still doesn't have safe and
> > hopeful cakephp_native solution ..... or may be I miss something.
>
> > I'm really stuck with this validation problem.
>
> > Give me some help pls.
>
> > P.S.
> > Set::filter is not a solution - if user doesn't fill obligatory field
> > filter deletes the name of the field from array and that breaks
> > validation. And allowEmpty rule is only enforced when there is an
> > actual fieldName index in the data array.
> > I even tried to set empty fields to NULL in beforeValidate but no
> > success again
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---