如何打开/关闭yii2中某些字段的前端表单验证? [英] How to switch on\off frontend form validation for some fields in yii2?
本文介绍了如何打开/关闭yii2中某些字段的前端表单验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在yii2视图中有困难的表格,其中某些字段显示或隐藏.它决定于用户字段选择,选择表单中的选项.我用自定义jquery文件编写此前端逻辑.一切都好.但是,当我提交表单时,隐藏的字段将保持未经验证的状态,并且什么也没有发生.当字段被隐藏时,如何取消通常的验证?当字段可见时,如何打开验证?
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?
推荐答案
禁用客户端验证.像这样开始您的活动表格.
To disable client side validation. Begin your active form like this.
ActiveForm::begin(['enableClientValidation'=>false]);
这篇关于如何打开/关闭yii2中某些字段的前端表单验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文