Ver Fonte

[Form][Twig] Reorganized the form template

Victor Berchet há 14 anos atrás
pai
commit
181fb56925

+ 26 - 27
src/Symfony/Bundle/TwigBundle/Resources/views/Form/div_layout.html.twig

@@ -1,18 +1,15 @@
-{% block field_rows %}
-{% spaceless %}
-    {{ form_errors(form) }}
-    {% for child in form %}
-        {{ form_row(child) }}
-    {% endfor %}
-{% endspaceless %}
-{% endblock field_rows %}
-
 {% block field_enctype %}
 {% spaceless %}
     {% if multipart %}enctype="multipart/form-data"{% endif %}
 {% endspaceless %}
 {% endblock field_enctype %}
 
+{% block field_label %}
+{% spaceless %}
+    <label for="{{ id }}"{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans }}</label>
+{% endspaceless %}
+{% endblock field_label %}
+
 {% block field_errors %}
 {% spaceless %}
     {% if errors|length > 0 %}
@@ -25,6 +22,15 @@
 {% endspaceless %}
 {% endblock field_errors %}
 
+{% block field_rows %}
+{% spaceless %}
+    {{ form_errors(form) }}
+    {% for child in form %}
+        {{ form_row(child) }}
+    {% endfor %}
+{% endspaceless %}
+{% endblock field_rows %}
+
 {% block field_rest %}
 {% spaceless %}
     {% for child in form %}
@@ -35,12 +41,6 @@
 {% endspaceless %}
 {% endblock field_rest %}
 
-{% block field_label %}
-{% spaceless %}
-    <label for="{{ id }}"{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans }}</label>
-{% endspaceless %}
-{% endblock field_label %}
-
 {% block attributes %}
 {% spaceless %}
     id="{{ id }}" name="{{ full_name }}"{% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
@@ -50,11 +50,20 @@
 
 {% block container_attributes %}
 {% spaceless %}
-    id="{{ id }}" 
+    id="{{ id }}"
     {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
 {% endspaceless %}
 {% endblock container_attributes %}
-    
+
+{% block form_widget %}
+{% spaceless %}
+    <div {{ block('container_attributes') }}>
+        {{ block('field_rows') }}
+        {{ form_rest(form) }}
+    </div>
+{% endspaceless %}
+{% endblock form_widget %}
+
 {% block field_widget %}
 {% spaceless %}
     {% set type = type|default('text') %}
@@ -245,7 +254,6 @@
 {% endspaceless %}
 {% endblock repeated_row %}
 
-
 {% block field_row %}
 {% spaceless %}
     <div>
@@ -256,15 +264,6 @@
 {% endspaceless %}
 {% endblock field_row %}
 
-{% block form_widget %}
-{% spaceless %}
-    <div {{ block('container_attributes') }}>
-        {{ block('field_rows') }}
-        {{ form_rest(form) }}
-    </div>
-{% endspaceless %}
-{% endblock form_widget %}
-
 {% block email_widget %}
 {% spaceless %}
     {% set type = type|default('email') %}