嗨,我正在尝试回显复选框,然后确定它们是否在我的控制器中被选中,如果是,则将它们添加到数组中。我遵循了 SO 的指南,但仍有问题。任何见解都非常感谢!
控制器代码:
foreach ($content['options'] as $option) {
$id = $option['id'];
$checked = (isset($_POST[$id])) ? true : false;
if ($checked == TRUE) {
array_push($recipientGroups, $id);
}
}
查看代码:
foreach ($options as $option) {
echo br(1);
echo $option['name'];
$checkboxattr = array(
'name' => $option['name'],
'value' => $option['name'],
'id' => $option['id']
); //'checkbox_'.
echo form_checkbox($checkboxattr);
echo "<span id='total_".strtolower($option['name'])."'></span>";
}