Hi Dave,

On the assumption, that all the possible values from the checkboxes,
can be found in the database, I would consider using:

http://book.cakephp.org/view/152/Adding-your-own-Validation-Methods

and in the validation method, validate that the submitted checkbox
values exists in the database! Just in case someone is trying to hack
your form! :)

If the values are not from the database, then you have to specify them
manually in the validate array, not a good solution!

Enjoy,
   John

On Jun 11, 9:37 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> I am trying to validate multiple checkboxes of a HABTM table. I managed to
> validate the values but cannot get a message to display. I have my own
> compare values in db against submitted data to validate but no message
> appears....
>
> I then see in the cookbook
>
> var $validate = array(
>           'function' => array(
>                 'allowedChoice' => array(
>                         'rule' => array('inList', array('Foo', 'Bar')),
>                         'message' => 'Enter either Foo or Bar.'
>                 )
>           )
>         );
>
> and
>
> var $validate = array(
>     'multiple' => array(
>         'rule' => array('multiple', array('in' => array('foo', 'bar'), 'min'
> => 1, 'max' => 3)),
>         'message' => 'Please select one, two or three options'
>     )
> );
>
> Would either of these work for validating multiple checkboxes?
> And how do I get the values of the fields when they say
> 'rule' => array('inList', array('Foo', 'Bar')),
>
> Or
>
> 'rule' => array('multiple', array('in' => array('foo', 'bar'), 'min' => 1,
> 'max' => 3)),
>
> Thanks,
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to