I am attempting to customise the markup of a form element in my Symfony form, however I am having difficulty targeting this element alone. I have read this section in the SF cookbook - but I am having difficulty applying it to my situation.
The form_row
block that I have extended does what I want it to do, however this applies to all form_row
s called in that template - how can I apply it to sizes
(which is an array) only?
view.html.twig:
{% form_theme form 'CRMPiccoProductBundle:CourseGuideRow:fields.html.twig' %}
{{ form_row(form.name) }}
{% for size in form.sizes %}
{{ form_row(size) }}
{% endfor %}
fields.html.twig:
{% block form_row %}
<td style="width: 75px; border-right: 2px solid #000000;">
{{ form_widget(form) }}
</td>
{% endblock %}
My form is called crmpicco_course_guide_row
:
/**
* @return string name
*/
public function getName()
{
return 'crmpicco_course_guide_row';
}
This results in this markup:
<td style="width: 75px; border-right: 2px solid #000000;">
<input type="text" class=" form-control"
required="required" name="crmpicco_course_guide_row[sizes][0]"
id="crmpicco_course_guide_row_sizes_0">
</td>