I am working on Yii2
. I am creating a dynamic form
using wbraganca
/
yii2-dynamicform. I have followed these steps and tried to create it.
Controller
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
]);
}
Create View
/* @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>
When I try to open my form I am getting this
PHP Notice – yii\base\ErrorException
Undefined variable: modelsTraiffSlabs
Any help would be highly appreciated
Just error 'modelsTraiffSlabs' => 'modelsTariffSlabs'