{% extends "collection/serialize/table/form.html" %}
{% set render_url = collection.serializer.render_url %}


<form{% block form_attrs %}
    {{ super() }}
    hx-on:htmx:config-request="
                               {% if collection.serializer.debug %}console.debug(event.detail.parameters);{% endif %}
                               {% if collection.serializer.push_url %}
                               const url = new URL(window.location)
                               url.searchParams.delete('{{ collection.name }}:page')
                               Object.entries(event.detail.parameters).forEach(([k, v]) => url.searchParams.set(k, v));
                               window.history.pushState({}, null, url);
                               {% endif %}
                               "
    {# catch plain submission/changes as well as changes from elements that
    live outside the form and select2-dropdowns that emit special change event
    and require a small delay for clearing them all at once via ClearFilters #}
    hx-trigger='
                               change,
                               submit,
                               change from:[form="{{ form_id }}"],
                               collection-refresh from:body,
                               collection-refresh from:#{{ form_id }},
                               change.htmx-select2 from:[form="{{ form_id }}"] delay:20'
    hx-target="closest .{{ base_class }}"
    hx-indicator="closest .{{ base_class }}"
    hx-get="{{ render_url }}"
    hx-swap="outerHTML"

{% endblock form_attrs %}>
