You can enable/disable ajax and client validations in active form.
$form = ActiveForm::begin([
'id' => 'signup-form',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'validationUrl' => Url::to('signup'),
]);
enableClientValidation
is by default enabled in ActiveForm. If you don't need client validation in form we can disable by assigning as false.enableAjaxValidation
is by default disabled in ActiveForm. If you want to enable it we have to add manually in ActiveForm like above.validationUrl
- if you want to keep all the validation coding in separate controller action for this form we can configure the activeform using validationUrl
. If we didn't set this, it will take the form's action value.The above two arguments will affect for whole form. If you want to check ajax validation only for particular field in the form you can add enableAjaxValidation
for that particular field. It will work only for that field not whole form.
For example in registration form you want to check the username already exist validation on time of user enter in the form. you can use this enableAjaxValidation
argument for that field.
echo $form->field($model, 'username', ['enableAjaxValidation' => true]);