{% macro render_groups(admin, form, groups, has_tab) %}
    <div class="row">

    {% for code in groups|filter(code => admin.formgroups[code] is defined) %}
        {% set form_group = admin.formgroups[code] %}

        <div class="{{ form_group.class|default('col-md-12') }}">
            <div class="{{ form_group.box_class }}">
                <div class="box-header">
                    <h4 class="box-title">
                        {% 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 ?? admin.translationDomain) }}
                        {% endif %}
                    </h4>
                </div>
                <div class="box-body">
                    <div class="sonata-ba-collapsed-fields">
                        {% if form_group.description %}
                            {% if form_group.translation_domain is defined and form_group.translation_domain is same as(false) %}
                                <p>{{ form_group.description|raw }}</p>
                            {% else %}
                                <p>{{ form_group.description|trans({}, form_group.translation_domain ?? admin.translationDomain)|raw }}</p>
                            {% endif %}
                        {% endif %}

                        {% for form_field_name in form_group.fields|filter(form_field_name => form[form_field_name] is defined) %}
                            {{ form_row(form[form_field_name]) }}
                        {% else %}
                            {% if form_group.empty_message != false %}
                                {% if form_group.empty_message_translation_domain is defined and form_group.empty_message_translation_domain is same as(false) %}
                                    <em>{{ form_group.empty_message }}</em>
                                {% else %}
                                    <em>{{ form_group.empty_message|trans({}, form_group.empty_message_translation_domain ?? admin.translationDomain) }}</em>
                                {% endif %}
                            {% endif %}
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    {% endfor %}
    </div>
{% endmacro %}
