Yii2- 未定义的变量:modelsTraiffSlabs

Yii2- Undefined variable: modelsTraiffSlabs

我正在研究 Yii2。我正在使用 wbraganca 创建一个 dynamic form / yii2-动态形式。我遵循了这些 steps 并尝试创建它。

控制器

 public function actionCreate()
{
    $model = new MdcTariff();
    $modelsTraiffSlabs = [new MdcTariffSlabs()];
    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        return $this->redirect(['view', 'id' => $model->id]);
    }

    return $this->render('create', [
        'model' => $model,
        'modelsTariffSlabs' => (empty($modelsTraiffSlabs)) ? [new MdcTariffSlabs()] : $modelsTraiffSlabs
    ]);
}

创建视图

/* @var $this yii\web\View */
/* @var $model MdcTariff */
/* @var $modelsTraiffSlabs MdcTariffSlabs */
<section class="content">
<div class="box">
    <div class="box-body">

<?= $this->render('_form', [
    'model' => $model,
    'modelsTariffSlabs' => $modelsTraiffSlabs,
]) ?>

</div>
</div>
</section>

当我尝试打开我的表单时,我得到了这个

PHP Notice – yii\base\ErrorException
Undefined variable: modelsTraiffSlabs

非常感谢任何帮助

只是错误'modelsTraiffSlabs' => 'modelsTariffSlabs'