OroCRM 如何禁用客户端验证?
OroCRM how to disable client side validation?
我可以为指定的 field/constraint 禁用客户端验证(通过 jQuery)吗?
我试过这个:
form_widget(form.myField,{'attr':{'data-validation':''}})
并且它禁用了客户端和后端验证。但我只需要禁用前端验证
要停用所有字段的客户端验证,请尝试使用:
{{ form_start(form, { 'attr': {'novalidate': ''} }) }}
好的,谢谢大家。今天Oro Core团队开发者Hryhorii Hrebiniuk给出了正确的解决方案:
So, if you want to remove all validation rule for the field with no
condition — you can use this approach. But there’s better approach.
Same as data-validation-optional-group attribute, there’s other useful
attribute — data-validation-ignore. If any field/group of fields is
wrapped in element with data-validation-ignore attribute, frontend
validator ignores validation rules for this field/group of fields. You
can add/remove this attribute in runtime to change validation
behavior.
OroCRM 论坛主题:http://www.orocrm.com/forums/topic/is-it-possible-to-inherit-frontend-validation
例如:
{# this wrapper div disables front-end jQuery Validate validation #}
<div data-validation-ignore>
{{ form_widget(form.field1) }}
{{ form_widget(form.field2) }}
{{ form_widget(form.field3) }}
...
{{ form_widget(form.fieldN) }}
</div>
我可以为指定的 field/constraint 禁用客户端验证(通过 jQuery)吗?
我试过这个:
form_widget(form.myField,{'attr':{'data-validation':''}})
并且它禁用了客户端和后端验证。但我只需要禁用前端验证
要停用所有字段的客户端验证,请尝试使用:
{{ form_start(form, { 'attr': {'novalidate': ''} }) }}
好的,谢谢大家。今天Oro Core团队开发者Hryhorii Hrebiniuk给出了正确的解决方案:
So, if you want to remove all validation rule for the field with no condition — you can use this approach. But there’s better approach. Same as data-validation-optional-group attribute, there’s other useful attribute — data-validation-ignore. If any field/group of fields is wrapped in element with data-validation-ignore attribute, frontend validator ignores validation rules for this field/group of fields. You can add/remove this attribute in runtime to change validation behavior.
OroCRM 论坛主题:http://www.orocrm.com/forums/topic/is-it-possible-to-inherit-frontend-validation
例如:
{# this wrapper div disables front-end jQuery Validate validation #}
<div data-validation-ignore>
{{ form_widget(form.field1) }}
{{ form_widget(form.field2) }}
{{ form_widget(form.field3) }}
...
{{ form_widget(form.fieldN) }}
</div>