浏览代码

Allow disabling translation on form fields (#4454)

This is what Symfony does in its Twig integration bundle, we should do
the same.
Grégoire Paris 8 年之前
父节点
当前提交
c53736c2de
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 3 0
      Resources/doc/reference/translation.rst
  2. 3 1
      Resources/views/Form/form_admin_fields.html.twig

+ 3 - 0
Resources/doc/reference/translation.rst

@@ -102,6 +102,9 @@ over-rides that setting for one of the fields:
         ->end()
         ->end()
     ;
     ;
 
 
+Translation can also be disabled on a specific field by setting
+``translation_domain`` to ``false``.
+
 Setting the label name
 Setting the label name
 ^^^^^^^^^^^^^^^^^^^^^^
 ^^^^^^^^^^^^^^^^^^^^^^
 
 

+ 3 - 1
Resources/views/Form/form_admin_fields.html.twig

@@ -131,7 +131,9 @@ file that was distributed with this source code.
         {% endif %}
         {% endif %}
 
 
         <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
         <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
-            {% if not sonata_admin.admin %}
+            {% if translation_domain is same as(false) %}
+                {{- label -}}
+            {% elseif not sonata_admin.admin %}
                 {{- label|trans({}, translation_domain) -}}
                 {{- label|trans({}, translation_domain) -}}
             {% else %}
             {% else %}
                 {{ label|trans({}, sonata_admin.field_description.translationDomain ?: admin.translationDomain) }}
                 {{ label|trans({}, sonata_admin.field_description.translationDomain ?: admin.translationDomain) }}