public function run() { $model = new RegisterForm(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } }
public function run() { $model = new RegisterForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->register()) { if ($user->login(false)) { return $this->controller->goHome(); } } } return Yii::$app->request->isAjax ? $this->controller->renderAjax('register', ['model' => $model]) : $this->controller->render('register', ['model' => $model]); }