I have this code in my _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
],
]); ?>
its working fine at first but when I add this layout code in the controller it didn't show the dropdown
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,
]);
}
if i do not put the layout code its working fine. but i need the form display in the layout.