I know I can add classes to <input>
fields in a form like this:
->add('foo', 'text', array('attr' => array('class' => 'foo-class'));
but how could I add a class to a <form>
tag?
For this, there's 2 solutions, either you do it in your controller or your view.
1) In your controller :
$form = $this->createForm(new FormType(), $data, ['attr' => ['class' => 'myClass']]);
2) In your view (Twig) :
{{ form_start(form, { 'attr' : { 'class': 'myClass' } }) }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With