Sunday, March 29, 2009

Re: Cake PHP 1.2 - Need Help For Posting Mulitple Checkboxes

You are unable to get the input name like data[Model][field][]. The
best we can get is like so data[Model][field][1].

<?php echo $form->checkbox('Model.field.1'); ?>

To loop it, just increment the number.

<?php echo $form->checkbox('Model.field.2'); ?>
<?php echo $form->checkbox('Model.field.3'); ?>

And then to go thru the data array

foreach ($this->data['Model']['field'] as $id => $value) {
if ($value > 0) {
// checked
}
}
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: