我试图通过从下拉菜单中选中复选框来更新学生班级列表。我选择了四个复选框。因此,调试正确显示 248,268,244,1220。Warning (2): Illegal string offset 'id' [APP/controllers/customers_controller.php, line 728]
但由于“classroom_id”而出现错误。无论如何只显示选定复选框ID的列表吗?
我正在尝试通过选中复选框来更新多个记录/行。如何将多个选定的 ID 发送到控制器?
任何帮助将不胜感激。
<?php echo $form->input('classroom_id', array('type' => 'select','empty' => '-- Select --','label' => false,'style'=>'width:254px;', 'options' => $classesfiltered,'validate'=>'required:true','div'=>'formfield')); ?>
<?php foreach ($students as $student) { ?>
<?php echo $form->input('Customer.'.$student['Customer']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$student['Customer']['id'], 'label' => false)); ?>
<?php } ?>
控制器
foreach($this->data['Customer'] as $key => $item) {
if ($item['id']) {
Debugger::Dump($this->data['Customer'][$key]);
}
}
输出
Warning (2): Illegal string offset 'id' [APP/controllers/customers_controller.php, line 728]
"classroom_id"
248
268
244
1220