Razip
Razip

Reputation: 155

Add a specific CSS-class to Symfony2 form

I haven't found a solution for the problem yet. I assume that I can do it through Twig, but I don't know how. I'll be thankful for help.

Upvotes: 0

Views: 96

Answers (1)

repincln
repincln

Reputation: 2059

When you render a widget, you can add class with name foo, like this:

{{ form_widget(form.name, {'attr': {'class': 'foo'}}) }}

If you want to add class foo to form element (tag), then you can use the same syntax:

{{ form(form, { 'attr': {'class': 'foo'} }) }}

Check out official documentation.

Upvotes: 1

Related Questions