Re: Multiple Checkbox Validation help

2009-06-12 Thread John Andersen

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



RE: Multiple Checkbox Validation help

2009-06-12 Thread Dave Maharaj :: WidePixels.com

Yep...thats what I have. The submitted data value array, I get the possible
values in the db and compare them against submitted values with my
checkValues function called in the model validation.. If any do not match
then we know someone was messing around return false...

That’s working and got the error message all set up.

Thanks again.

Dave



-Original Message-
From: John Andersen [mailto:j.andersen...@gmail.com] 
Sent: June-12-09 3:50 AM
To: CakePHP
Subject: Re: Multiple Checkbox Validation help


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