我想主题我的形式,使得该领域的标签显示当前语言环境,像如何将变量传递给form_theme?
名称(中文):
所以我想改写块generic_label这样的:
{# 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 %}
并导入它在我的模板:
{% form_theme options 'myBundle:Object:form_theme.html.twig' %}
但应用程序变量在表单模板中不可访问。 如何将变量传递给表单主题?
也不管用,'{%form_theme edit_form _self%} {%block field_label%} {{app.session.locale}} {%endblock%}'给出'变量“app”不存在'。我要创建一张票 – Matthieu 2012-01-08 10:59:17
https://github.com/symfony/symfony/issues/3058 – Matthieu 2012-01-08 11:14:29