Here is choice_widget template from Symfony2. I need to print the label text itself without markup, that is without calling form_label template but simply echoing the text.
The line to be sostituted is {{ form_label(child) }}. I've tried child.label but it's not working (there is no property label...). Also tried label but it prints the label of the whole widget, not the label of the current child element.
{% block choice_widget %}
{% spaceless %}
{% if expanded %}
<div {{ block('widget_container_attributes') }}>
{% for child in form %}
{{ form_widget(child) }}
{{ form_label(child) }} {# here! #}
{% endfor %}
</div>
{% else %}
{# print <select> element #}
{% endif %}
{% endspaceless %}
{% endblock choice_widget %}
Form fields' attributes are stored in their ''vars'' property :
{{ child.vars.label }}
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