Why ajax validation trigers before client validation?
I have this code in view:
<?php $form = ActiveForm::begin([
'id' => 'registration-form',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
]); ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password', ['enableAjaxValidation'=>false, 'enableClientValidation'=>true])->passwordInput() ?>
<?= Html::submitButton(Yii::t('user', 'Sign up'), ['class' => 'btn btn-success btn-block']) ?>
<?php ActiveForm::end(); ?>
And in controller:
public function actionRegister()
{
$model = $this->module->manager->createRegistrationForm();
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->register()) {
return $this->render('finish');
}
return $this->render('register', [
'model' => $model
]);
}
Only Username and Email Unique validators must trigger ajax calls to the server.
But there are ajax calls for other validators too ( even for simple Required validation ).
Client validation work only for Password field, because AjaxValidation is disabled there.
What could be the problem?
I appreciate any help!