I want to use a theme of my form so that the field label displays the current language, something like
Name (en):
So, I would like to rewrite the generic_label block as follows:
{# form_theme.html.twig #} {% block generic_label %} {% spaceless %} {% if required %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' required'}) %} {% endif %} <label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans }} (app.session.locale)</label> {% endspaceless %} {% endblock %}
and import it into my template:
{% form_theme options 'myBundle:Object:form_theme.html.twig' %}
but the application variable is not available in the form template. How to pass a variable to a form theme?
Matthieu
source share