Yii2为什么没有显示字段表格?

时间:2018-11-24 09:05:46

标签: php yii2 yii2-advanced-app

我的_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

0 个答案:

没有答案