{% set dropdownAction ={}  %}
{% for action in actions %}


    {% if action.group is defined and action.group==true %}
        {% set dropdownAction = dropdownAction|merge({(loop.index0): action}) %}
    {% else %}
        {% if 'list' == action.name %}
            {% set action_href = request_parameters.referer|default('') ? request_parameters.referer|easyadmin_urldecode : path('easyadmin', request_parameters|merge({ action: 'list' })) %}
        {% elseif 'method' == action.type %}
            {% set action_href = path('easyadmin', request_parameters|merge({ action: action.name, id: item_id })) %}
        {% elseif 'route' == action.type %}
            {% set action_href = path(action.name, request_parameters|merge({ action: action.name, id: item_id })) %}
        {% endif %}

        {{ include(action.template, {
            action: action,
            action_href: action_href,
            is_dropdown: is_dropdown|default(false),
            item: item,
            item_id: item_id,
            request_parameters: request_parameters,
            translation_domain: translation_domain,
            trans_parameters: trans_parameters,
        }, with_context = false) }}
    {% endif %}
{% endfor %}
{% if dropdownAction|length > 0 %}
    <div class="btn-group">
        <button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-icon"  aria-expanded="false">
            <span class="sr-only">Toggle Dropdown</span>
            <div class="dropdown-menu   dropdown-menu-right" role="menu">
                {% for action in dropdownAction %}

                    {% if 'list' == action.name %}
                        {% set action_href = request_parameters.referer|default('') ? request_parameters.referer|easyadmin_urldecode : path('easyadmin', request_parameters|merge({ action: 'list' })) %}
                    {% elseif 'method' == action.type %}
                        {% set action_href = path('easyadmin', request_parameters|merge({ action: action.name, id: item_id })) %}
                    {% elseif 'route' == action.type %}
                        {% set action_href = path(action.name, request_parameters|merge({ action: action.name, id: item_id })) %}
                    {% endif %}

                    {{ include(action.template, {
                        action: action,
                        action_href: action_href,
                        is_dropdown: true,
                        item: item,
                        item_id: item_id,
                        request_parameters: request_parameters,
                        translation_domain: translation_domain,
                        trans_parameters: trans_parameters,
                    }, with_context = false) }}
                {% endfor %}
            </div>
        </button>
    </div>

{% endif %}
