mercredi 26 août 2015

How can I create an array of numbers based on which checkboxes are checked in a form?

I need to allow multiple values to be selected, and I want to create an array of the selected values. Here is what I have so far:

<p>Select Multiple Values
    <?php echo $this->Form->create(); ?>
    <?php foreach($possibilities as $possibility):
     echo $this->Form->input($possibility['name'], 
         ['type' => 'checkbox', 'value' => $possibility['id']]);
    endforeach; ?>
    <?php echo $this->Form->button(__('Submit'));
    echo $this->Form->end(); ?></p>

How can I check this form to see what values have been selected and store them in an array?




Aucun commentaire:

Enregistrer un commentaire