Search code examples
jqueryvalidationyii2

How to switch on\off frontend form validation for some fields in yii2?


I have got difficult form in yii2 view, where some fields show or hide. It decide from user field choises, select options in the form. I write this frontend logic with custom jquery file. All is ok. But when I submit form - hidden fields stay without validation and nothing is happend.How I can kill ofrontend validation, when fields are hiiden and switch on it, when fields are visible?


Solution

  • To disable client side validation. Begin your active form like this.

    ActiveForm::begin(['enableClientValidation'=>false]);