Ver código fonte

Add ability to display nested arrays (#4163)

This is not just a feature, it also fixes an error that appears when the displayed array contains an array.
technetium 8 anos atrás
pai
commit
114ee15f4b
1 arquivos alterados com 10 adições e 3 exclusões
  1. 10 3
      Resources/views/CRUD/list_array.html.twig

+ 10 - 3
Resources/views/CRUD/list_array.html.twig

@@ -8,11 +8,18 @@ For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.
 file that was distributed with this source code.
 
 
 #}
 #}
+{%  macro render_array(value) %}
+    {% for key, val in value %}
+        {% if val is iterable %}
+            [{{ key }} => {{ _self.render_array(val) }}}]
+        {%  else %}
+            [{{ key }} => {{ val }}]
+        {%  endif %}
+    {% endfor %}
+{% endmacro %}
 
 
 {% extends admin.getTemplate('base_list_field') %}
 {% extends admin.getTemplate('base_list_field') %}
 
 
 {% block field %}
 {% block field %}
-    {% for key, val in value %}
-        [{{ key }} => {{ val }}]
-    {% endfor %}
+    {{ _self.render_array(value) }}
 {% endblock %}
 {% endblock %}