Including novalidate attribute into Symfony2 twig template Including novalidate attribute into Symfony2 twig template symfony symfony

Including novalidate attribute into Symfony2 twig template


You need a key/value pair:

{{ form_start(contact, {attr: {novalidate: 'novalidate'}}) }}


If you want to add novalidatein all the forms of your app, create a twig template like this:

{% extends 'form_div_layout.html.twig' %}{# FORM START #}{% block form_start %}<form  action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% endblock form_start %}

Documentation: Form Theme


You can set form novalidate attribute to symfony 2 form object like this

$form = $this->createForm(new ClientType(), $clientEntity, array(    'action' => $this->generateUrl('client_create'),    'method' => 'POST',    'attr'=>array('novalidate'=>'novalidate') //add novalidate attribute to form));