Answer the question
In order to leave comments, you need to log in
What is the best way to make a wizard form in yii2?
I have a form where the order of goods of the wizard form type takes place in several stages ...
1) I can implement it in one view through the tab-pane, but how to validate the forms from the transition of one tab to another ... Or is there another solution altogether ?
2) I was advised to do it like "actionCreate", but after a successful save, redirect to the next step of filling out the questionnaire, but then there will be extra 2-3 tables and models ... as a working example below:
public function actionShipping($id)
{
$model = new OrderDeliveryMethod();
$model->order_id = $id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['payment', 'id' => $model->id]);
} else {
return $this->render('shipping', [
'model' => $model,
]);
}
}
public function actionPayment($id)
{
$model = new OrderPaymentMethod();
$model->order_id = $id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['review', 'id' => $model->id]);
} else {
return $this->render('payment', [
'model' => $model,
]);
}
}
public function actionReview($id)
{
return $this->render('review', [
'model' => $this->findModel($id),
]);
}
Answer the question
In order to leave comments, you need to log in
1) I can implement it in one view through the tab-pane, but how to validate the forms from the transition of one tab to another ... Or is there another solution altogether?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question