Контроллер
Код: Выделить всё
public function actionTable($id)
{
$this->layout = 'custom';
$model = Deal::findOne($id);
$td1 = Parse::findOne(['deal_id' => $model->id, 'table_id' => 1]);
$td2 = Parse::findOne(['deal_id' => $model->id, 'table_id' => 2]);
$td3 = Parse::findOne(['deal_id' => $model->id, 'table_id' => 3]);
if ($td1->load(Yii::$app->request->post()) && $td1->save()) {
Yii::$app->session->setFlash('success', "Человек добавлен");
return $this->refresh();
}
if ($td2->load(Yii::$app->request->post()) && $td2->save()) {
Yii::$app->session->setFlash('success', "Человек добавлен");
return $this->refresh();
}
if ($td3->load(Yii::$app->request->post()) && $td3->save()) {
Yii::$app->session->setFlash('success', "Человек добавлен");
return $this->refresh();
}
return $this->render('table', [
'model' => $model,'td1' => $td1,'td2' => $td2,'td3' => $td3
]);
}
Код: Выделить всё
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($td1, 'td1') ?>
<?php echo Html::submitButton('Сохранить', [
'class' => 'l-btn'
]); ?>
<?php ActiveForm::end(); ?>
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($td2, 'td1') ?>
<?php echo Html::submitButton('Сохранить', [
'class' => 'l-btn'
]); ?>
<?php ActiveForm::end(); ?>
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($td3, 'td1') ?>
<?php echo Html::submitButton('Сохранить', [
'class' => 'l-btn'
]); ?>
<?php ActiveForm::end(); ?>
Не подскажите что делаю не так?