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 amnahyii2usermodelsformsLoginForm $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"));
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…