我的_form.php中有此代码
<?= $form->field($model, 'receiver_id')->widget(Select2::classname(),[
'data'=>ArrayHelper::map(User::findAll(['category' => 'customer']),'username','username'),
'language' => 'en',
'options' => ['placeholder' => 'select student id ...'],
'pluginOptions' => [
'allowClear' => true
],
]); ?>
起初工作正常,但是当我在控制器中添加此布局代码时,它没有显示下拉列表
public function actionCreate()
{ $this->layout = 'lecLayout';
$model = new Privatemessage();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
如果我不放置布局代码,它将正常工作。但我需要在布局中显示表单。