Answer the question
In order to leave comments, you need to log in
Yii2 how to make a redirect in a modal window on successful form validation?
Hello everyone, help me understand, I can not figure out how to implement the idea correctly. In yii2, the idea is to implement a two-step registration in a modal window. Click "Register", a modal window opens with fields
public function actionSignupStepOne()
{
$model = new Signup;
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
if ($user = $model->save()) {
return $this->redirect('site/signup-step-two');
} else {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
}
return $this->renderAjax('signup-step-one', [
'model' => $model,
]);
}
Answer the question
In order to leave comments, you need to log in
Good afternoon.
This line is a redirect to another page
. Return some value instead of a redirect, and in 'success' check what is returned. If the desired value is returned, then show the second form.
Or try to return the form in the same way as the first
return $this->renderAjax('signup-step-two', [
'model' => $model,
]);
$user = $model->save()
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question