Yii2 почему форма поля не появляется? - PullRequest
0 голосов
/ 24 ноября 2018

У меня есть этот код в моем _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,
    ]);
}

если я не поставлю код компоновки, он работает нормально.но мне нужно отображение формы в макете.

this is what happens when I run the code. the receiver id does not appear

...