Search code examples
symfonysymfony-formsorocrm

OroCRM how to disable client side validation?


Can i disable client side validation (via jQuery) for specified field/constraint?

I tried this: form_widget(form.myField,{'attr':{'data-validation':''}})

and it disabled both client side and backend validation. But i need to disable frontend validation only


Solution

  • Ok, thanks to all of you. Today the Oro Core team developer Hryhorii Hrebiniuk provide a correct solution:

    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 forum topic: http://www.orocrm.com/forums/topic/is-it-possible-to-inherit-frontend-validation

    For example:

    {# 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>