I do agree for the formating.
But the problem relies on the fact that field1, field2...belong to a
multidimensional array(from the view), this is why I can't use  :
var $validate = array(
    'field1' => array(
        'ruleName' => array(
            'rule' => 'ruleName',
        )
    ),

but should be something like:
var $validate = array(
    'myarray.field1' => array(
        'ruleName' => array(
            'rule' => 'ruleName',
        )
    ),
which doesn't work.

In my validation rule, I have to specify the name of the array
concerning the field, but I don't now how...
Cheers

On Dec 14, 7:00 pm, thatsgreat2345 <[email protected]> wrote:
> var $validate = array(
>     'field1' => array(
>         'ruleName' => array(
>             'rule' => 'ruleName',
>         )
>     ),
>    'field2'  => array(
>         'ruleName' => array(
>             'rule' => 'ruleName',
>         )
>   )
> );
>
> is how it should be, check the book for more information on validation
> and formattinghttp://book.cakephp.org/view/133/Multiple-Rules-per-Field
>
> On Dec 14, 8:33 am, "[email protected]" <[email protected]>
> wrote:
>
> > Hello everyone,
>
> > I have the following misunderstanding,
>
> > In my view, I want to create a group of html inputs. To do so, let's
> > have the following inputs :
> >  echo $form->input('myarray.field1');
> >  echo $form->input('myarray.field2');
> >  echo $form->input('myarray.field3');
>
> > In my controller, I can extract each value (or key) as :
> > foreach ($this->data['Post']['myarray'] as $key => $value) {
> >         //Do whatever you want with the $key/$value
>
> > }
>
> > It is ok so far, but the problem lies on my model when I want to apply
> > some validation rules.
> > Indeed, I tried lots of things such as :
> > var $validate = array('myarray.field1' => array(
> >                         'rule' => array('notEmpty')
> >                 )
> > or
> > var $validate = array('myarray' => array('field1' =>array(
> >                         'rule' => array('notEmpty')
> >                 ))
>
> > But it doesn't work! I can't apply a rule for a precise field within
> > my array.
> > I'll be very hapy if someone could highlight the error or give some
> > pointers!
> > Cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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