它将不显示默认选择值在我的多选下拉列表和我没有得到这mistak.is下拉列表接受数组为默认选择数组列表
public function actionCreate()
{
.......
$cust= implode('_',$_POST['supplier'] ['manufacture']);
$model->customer = $cust;
$model->save();
........
}
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->customer = explode('_',$model->customer);
if ($model->load(Yii::$app->request->post())) {
$cust= implode(',',$_POST['supplier']['manufacturer']);
$model->customer = $cust`enter code here`;
$model->save();
return $this->redirect(['view', 'id' => $model->ID]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
查看
<?=
$form->field($model, 'car_manufacturer[]')->dropDownList($model->getcustinfo(), [
'multiple'=>'multiple',
'class'=>'chosen-select input-md required',
]);
?>
2条答案
按热度按时间gajydyqb1#
在选项中传递
selected value
:您应该在选项中传递
array
:您可以使用
foreach
循环来生成此array
。oknwwptz2#
您应该只使用属性名称。