After clicking the button to send the form, if some reuired fields are not filled in, the response will come about the fields that need to be filled. You can somehow show these errors, but only in a separate block, or for example flash -
foreach($model->errors as $error) Yii::$app->session->setFlash('error', $error);
How can this be done? Here is the controller code, ajax validation
public function actionCreate() { $model = new ObjectForm(); $model->scenario = 'create'; if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) && $model->saveObject()) { return $this->redirect(['index']); } else { return $this->render('/objects/create', [ 'model' => $model, ]); } } 