{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}
<div class="sonata-ba-tabs">
    {% for nested_group_field in form.children %}
        <div>
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                    {% for form_group in associationAdmin.formgroups %}
                        <li class="{% if loop.first %}active{% endif %}">
                            <a
                                href="#{{ id }}_{{ loop.parent.loop.index }}_{{ loop.index }}"
                                data-toggle="tab"
                            >
                                <i class="icon-exclamation-sign has-errors hide"></i>
                                {% if form_group.translation_domain is defined and form_group.translation_domain is same as(false) %}
                                    {{ form_group.label }}
                                {% else %}
                                    {{ form_group.label|trans({}, form_group.translation_domain ?? associationAdmin.translationDomain) }}
                                {% endif %}
                            </a>
                        </li>
                    {% endfor %}
                </ul>

                <div class="tab-content">
                    {% for name, form_group in associationAdmin.formgroups %}
                        <div
                            class="tab-pane{% if loop.first %} active{% endif %}"
                            id="{{ id }}_{{ loop.parent.loop.index }}_{{ loop.index }}"
                        >
                            <fieldset>
                                <div class="sonata-ba-collapsed-fields">
                                    {% for field_name, form_field_name in form_group.fields|filter(form_field_name => nested_group_field.children[form_field_name] is defined) %}
                                        {% set nested_field = nested_group_field.children[form_field_name] %}
                                        <div class="sonata-ba-field-{{ id }}-{{ field_name }}">
                                            {% if associationAdmin.formfielddescriptions[field_name] is defined %}
                                                {{ form_row(nested_field) }}
                                                {% set dummy = nested_group_field.setrendered %}
                                            {% else %}
                                                {{ form_row(nested_field) }}
                                            {% endif %}
                                        </div>
                                    {% endfor %}
                                </div>
                            </fieldset>
                        </div>
                    {% endfor %}
                </div>
            </div>

            {% if nested_group_field['_delete'] is defined %}
                {{ form_row(nested_group_field['_delete'], {'label': 'action_delete', 'translation_domain': 'SonataAdminBundle'}) }}
            {% endif %}
        </div>
    {% endfor %}
</div>
