{% trans_default_domain "admin" %} {{ form_start(form) }} {% set wasCompound = false %} {{ form_errors(form) }} {% for child in form.children %} {% set hidden = ('hidden' in child.vars.block_prefixes) %} {% set compound = (child.vars.compound is defined and child.vars.compound and child.vars.datetimepicker is not defined) %} {% if loop.first %}{# if it's the first item, make sure the panel is opened #}
{% elseif compound %}{# if it's a compound item, create a new panel #} {% if not wasCompound %}
{% endif %}
{% elseif wasCompound and not hidden %}{# if the previous item was compound and current item is not compound, open a new panel #}
{% endif %} {% if compound %}{# if current item is compound, render label as panel heading and add panel body #} {% set wasCompound = true %} {% if child.vars.label != false or child.vars.label is null %}

{{ form_label(child) }}

{% endif %}
{{ form_errors(child) }} {{ form_widget(child) }} {% if child.vars.unclosedCompound is defined and child.vars.unclosedCompound %} {% set wasCompound = false %} {% else %}
{% endif %} {% else %}{# if not compound, just render form rows #} {% if loop.first %}
{% endif %}{# if it's the very first form item, a panel body should be opened #} {{ form_row(child) }} {% if loop.last and not (hidden and wasCompound) %}
{% endif %}{# if it's the last form item, close the panel body #} {% if not hidden %} {% set wasCompound = false %} {% endif %} {% endif %} {% endfor %}
{{ form_end(form) }}