I have some *Type form classes and a forms.html.twig to customize form appearance. By default, in this file the labels are rendered with this block:
<label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans }}</label>
I’d like to add a prefix to the label ir order to organize my translations. For example let’s say I have a CustomerType, then I’d like my labels to be like:
<label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{{ 'Customer.' ~ label|trans }}
</label>
I want to be able to pass that 'Customer' string to the FormBuilder in such a way that I am able to use it like:
<label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{{ prefix ~ '.' ~ label|trans }}
</label>
or maybe:
<label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
{{ form.prefix ~ '.' ~ label|trans }
}</label>
Does someone know how to achieve this?
With Symfony 2.1
Declare this extension as a service
For more informations, see the documentation.