/** @inheritdoc */ public function run() { if ($this->model === null) { $this->model = Yii::createObject(ModelMapHelper::LoginForm()); } $this->formOptions['action'] = ['@login']; return $this->render($this->viewFile, ['model' => $this->model, 'formOptions' => $this->formOptions]); }
/** @inheritdoc */ public function run() { /** @var LoginForm $model */ $model = Yii::createObject(ModelMapHelper::LoginForm()); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; // perform AJAX validation echo ActiveForm::validate($model); Yii::$app->end(); return ''; } if ($model->login()) { $returnUrl = Yii::$app->request->get('returnUrl'); if ($returnUrl !== null) { return $this->controller->redirect($returnUrl); } else { return $this->controller->goBack(); } } } return $this->controller->render($this->viewFile, ['model' => $model, 'formOptions' => $this->formOptions]); }