如何打开/关闭 yii2 中某些字段的前端表单验证? [英] How to switch onoff frontend form validation for some fields in yii2?

查看:22
本文介绍了如何打开/关闭 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆