From 2882754410e8623f676533c3512d0e3ea86f6b93 Mon Sep 17 00:00:00 2001 From: Jan Storm Date: Mon, 21 Dec 2020 15:20:48 +0100 Subject: [PATCH] Improves getting of first array element (#6722) When working with adding and removing entities from the CollectionType field, it can happen that the array index not starts with 0 but has an length > 0. This leads to an error since that index 0 is unset. So using twig first function here to handle this case. --- .../views/CRUD/Association/edit_many_to_many.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/CRUD/Association/edit_many_to_many.html.twig b/src/Resources/views/CRUD/Association/edit_many_to_many.html.twig index 329ea535c4..5312384c6e 100644 --- a/src/Resources/views/CRUD/Association/edit_many_to_many.html.twig +++ b/src/Resources/views/CRUD/Association/edit_many_to_many.html.twig @@ -17,7 +17,7 @@ file that was distributed with this source code. - {% for field_name, nested_field in form.children[0].children %} + {% for field_name, nested_field in (form.children|first).children %} {% if field_name == '_delete' %} {% else %}
{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}