CakePHP multiple checkboxes with JS helper
I'm using Cake 2.3.8 and I have 4 checkboxes that are part of a form. I'm
using the JS helper to submit the checkboxes when any single checkbox is
clicked. It's being used for rows in a table, so I'd prefer to do it this
way rather than have a submit button for each row. Right now, only the
first checkbox is actually submitting data. The other's are triggering the
JS helper, there's just no data being sent.
<tr>
<td>
<?php
echo $this->Form->create('account_settings');
echo $this->Form->checkbox('change_rate', array('value' => 1));
?>
</td>
<td>
<?php
echo $this->Form->checkbox('edit', array('value' => 1 ));
?>
</td>
<td>
<?php
echo $this->Form->checkbox('refund', array('value' => 1 ));
?>
</td>
<td>
<?php
echo $this->Form->checkbox('news', array('value' => 1 ));
echo
$this->Form->input('account_id',array('type'=>'hidden','value'=>$account['User']['id']));
echo $this->Form->end();
?>
</td>
</tr>
Is it possible to do something like this so that I can use individual
table cells for each checkbox?
I've seen on Cake's documentation for multiple checkboxes, but I'm just
wondering if that's Cake's way of keeping code short. Is it possible to
put each checkbox in it's own cell?
$options = array(
'Value 1' => 'Label 1',
'Value 2' => 'Label 2'
);
echo $this->Form->select('Model.field', $options, array(
'multiple' => 'checkbox',
'disabled' => array('Value 1')
));
No comments:
Post a Comment