Here’s a bit of code from a codeigniter View:
<li>
<label>Assign volunteer to event:</label><br />
<? foreach ($all_vols as $vol) :?>
<?=form_checkbox('volunteers', $vol) ?>
<?=$vol['username']?>
<br />
<? endforeach ?>
</li>
I’m expecting there to be an array named volunteers in the $_POST variable. Instead, what I’m getting is 'volunteers' => string('array'). Any thoughts what is happening here?
You cannot use an array as a second argument of form_checkbox() when used in this way, and
$volis likely to be an array as you use$vol['username']later on. You’re confounding the form helper, which takes the first parameter to be used as the ‘name’ attribute and the second as its ‘value’.Try: