Reputation: 708
Using Symfony 3 and building a form field like this:
$builder
->add('tittle')
->add('price');
The result is something like:
<div>
<label ...></label>
<input ...>
</div>
and I want the result to include custom css classes in the wrapping div
, like:
<div class='wrap-title'>
<label ...></label>
<input ...>
</div>
<div class='wrap-price'>
<label ...></label>
<input ...>
</div>
Trying to do as described here doesn't offer a way to add a class to the wrapping div
, just the things inside it.
I don't want to use the bootstrap themes. I really need to add something of my own as a class there. Is that even possible?
Upvotes: 0
Views: 1638
Reputation: 665
I hope this answer can helps you:
I do not think it's possible to create div element inside the formbuilder.
If you can use Twig then you can render each of the three parts of the field individually inside a div having your custom class
<div class=wrap-title"">
{{ form_label(form.title) }}
{{ form_errors(form.title) }}
{{ form_widget(form.title) }}
</div>
<div class=wrap-price"">
{{ form_label(form.price) }}
{{ form_errors(form.price) }}
{{ form_widget(form.price) }}
</div>
Upvotes: 4