There is an actionCreate , a separate link to ajax validation is registered in the form, i.e.
<?php $form = ActiveForm::begin([ 'enableClientValidation' => false, 'enableAjaxValidation' => true, 'validationUrl' => '/item/validate', ]); ?> The insert script is registered in the actionCreate controller ItemController
public function actionCreate() { $model = new Item([ 'scenario' => 'insert' ]); } And actionValidate
public function actionValidate() { if ( Yii::$app->request->isAjax ) { $model = new Item(); // получить здесь сценарий или текущую модель if ( $model->load( Yii::$app->request->post() ) ) { if ( $errors = ActiveForm::validate( $model ) ) { Yii::$app->response->format = Response::FORMAT_JSON; return $errors; } else { return true; } } } } The question is how to make validation work according to the script, i.e. in this case insert ?