Is there any way I can just display validation errors in Yii2 without a redirect or refresh?
This is my default controller code performing the login action, I would like to highlight the text fields when the data entered does not match the data in the database, a simple validation against the database.
public function actionLogin() { /** @var \amnah\yii2\user\models\forms\LoginForm $model */ $model = $this->module->model("LoginForm"); // load post data and login $post = Yii::$app->request->post(); if ($model->load($post) && $model->validate()) { $returnUrl = $this->performLogin( $model->getUser(), $model->rememberMe ); return $this->redirect($returnUrl); } return $this->render('login', compact("model")); } https://stackoverflow.com/questions/65610055/display-validation-errors-without-page-refresh January 07, 2021 at 05:52PM
没有评论:
发表评论