Thanks bujanga. I'll give that a try.

Farez

On Sep 20, 9:13 pm, bujanga <[EMAIL PROTECTED]> wrote:
> Here is an example of a working rule with a required condition.
>
> var $validate = array(
>         'owner_id'      => array(
>                 'number'        => array(
>                         'rule'  => array('numeric'),
>                         'on'    => 'create',
>                         'required' => true,
>                         'allowEmpty' => false,
>                         'message'       => 'Owner ID must exist!'
>                 )
>         )
> );
>
> On 9/19/07, Farez <[EMAIL PROTECTED]> wrote:
>
>
>
> > thanks grigri. seems to be working fine for me without 'allowEmpty'.
> > but the 'required' rule is still a mystery to me.
>
> > On Sep 19, 9:40 am, grigri <[EMAIL PROTECTED]> wrote:
> > > I ran into this too - you need to add the 'allowEmpty' attribute too:
>
> > > 'email' => array('rule'=>VALID_NOT_EMPTY, 'allowEmpty' => true)
>
> > > On Sep 18, 1:51 pm, Farez <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I'm wondering if I'm doing something wrong here (have searched docs,
> > > > sources and archives and can't find an answer).
>
> > > > The 'required' rule seems to be broken as it still reports an error
> > > > even when the field is not empty. The rule I have is:
>
> > > > 'email' => array('rule'=>'required')
>
> > > > I traced this to this part of the code in Model:invalidFields():
>
> > > > if (method_exists($this, $rule)) {
> > > >         $ruleParams[] = array_diff_key($validator, $default);
> > > >         $valid = call_user_func_array(array(&$this, $rule), 
> > > > $ruleParams);} elseif (method_exists($Validation, $rule)) {
>
> > > >         $valid = call_user_func_array(array(&$Validation, $rule),
> > > > $ruleParams);} elseif (!is_array($validator['rule'])) {
>
> > > >         $valid = preg_match($rule, $data[$fieldName]);
>
> > > > }
>
> > > > where it always lands on the preg_match(...) line in the last
> > > > condition, where it tries to preg_match() $rule which has a value of
> > > > 'required', against the data field.
>
> > > > Anyway, I tried using a pattern instead of 'required' and it works,
> > > > like this:
>
> > > > 'email' => array('rule'=>VALID_NOT_EMPTY)
>
> > > > ... but I'm wondering if the 'required' rule is working in 1.2?
>
> > > > Cheers,
> > > > Farez


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to