Skip to content

Commit

Permalink
Improves getting of first array element (#6722)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JanStorm authored Dec 21, 2020
1 parent 2cd0803 commit 2882754
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ file that was distributed with this source code.
<table class="table table-bordered">
<thead>
<tr>
{% for field_name, nested_field in form.children[0].children %}
{% for field_name, nested_field in (form.children|first).children %}
{% if field_name == '_delete' %}
<th>{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}</th>
{% else %}
Expand Down

0 comments on commit 2882754

Please sign in to comment.