Since human stupidity is limitless, and my time for a diploma is not, I will create 501 topics about non-working ajax-validation.
There is a registration form:
<?php $form = ActiveForm::begin([ 'id' => 'reg-form', 'enableClientValidation' => true, 'enableAjaxValidation' => true ]) ?> //тут вот поля всяческие <?php ActiveForm::end() ?> There is a controller (it is not all, there is still the input form is processed first, if it matters - I will add):
public function actionLogin() { if (!Yii::$app->user->isGuest) { return $this->goHome(); } $this->layout = 'alter'; //форма регистрации $modelSignUp = new SignUpForm(); $this->performAjaxValidation($modelSignUp); if (isset($_POST['SignUpForm'])) { //массово присваиваем элементы массива в переменные модели $modelSignUp->attributes = Yii::$app->request->post('SignUpForm'); if($modelSignUp->validate() && $modelSignUp->signup()){ return $this->goHome(); } return $this->render('login', [ 'modelLog' => $modelLog, 'modelSignUp' => $modelSignUp ]); } There is a function performAjaxValidation, written using Ctrl + C / Ctrl + V, and not using CRUD (IMHO, important):
protected function performAjaxValidation($model) { // var_dump($_POST['ajax']); if(isset($_POST['ajax']) && $_POST['ajax']==='reg-form') { echo ActiveForm::validate($model); Yii::app()->end(); } } The meaning of the required validation is checking for the uniqueness of the postal address. There is a rule:
['email', 'unique', 'targetClass' => '\app\models\User', 'message' => 'Аккаунт с такой почтой уже зарегистрирован.'], And nothing works (so also the form is not sent, it is useless to press the button))). As soon as I remove, everything related to the Ajax - everything is sent, recorded, if the mail is repeated - it gives a validation error after the form is submitted. However, due to the layout features, I need an Ajax.
Where I nakosyachila?
Update: By the way, when you click on the button, you get an error 505. 
Yii::app()->end()from Yii 1, and will not work - Blacknife