{% import 'ohmyadmin/lib/forms.html' as forms %}

<x-modal data-modal-wrapper hx-target="this" hx-swap="outerHTML">
    <div class="modal">
        <form class="modal-dialog" method="post" hx-post="{{ request.url }}">
            <header>
                {% block header %}
                    <span>{{ action.label }}</span>
                    <button type="button" @click="closeModal">
                        {{ tabler_icon('x') }}
                    </button>
                {% endblock %}
            </header>
            <main>
                {% if action.message %}
                    <div>{{ action.message }}</div>
                    {% if form.data|length %}
                        <br/>
                    {% endif %}
                {% endif %}
                <div>
                    {% for field in form %}
                        {{ forms.form_field(field) }}
                    {% endfor %}
                </div>
            </main>
            <footer>
                {% for action in actions %}
                    {{ action.render(request) }}
                {% endfor %}
            </footer>
        </form>
    </div>
</x-modal>
