这是我的add.ctp
<?php
$options = ['Offer' => 'Offer','COA' => 'COA','Purchase' => 'Purchase'];
echo $this->Form->select('product_data_tests.n2.purpose', $options, ['multiple' => 'checkbox']);
?>
在控制器下:
foreach ($this->request->data['product_data_tests'] as $key => &$productDataCheck){
$productDataCheck["purpose"]=implode(", ",$productDataCheck["purpose"]);
}
if ($this->ProductsMaster->save($productsMaster)) {
$this->Flash->success(__('The {0} has been saved.', 'Products Master'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The {0} could not be saved. Please, try again.', 'Products Master'));
}
在提交表单时,它无法保存并且收到错误无法保存。请再试一次。 对一个输入字段中的“保存多个”复选框进行替换或更正