{% set grid = cva({
    base: '',
    variants: {
        width: {
            '1/3': 'md:col-span-2',
            '1/2': 'col-span-2 md:col-span-3',
            '2/3': 'col-span-2 md:col-span-4',
            '1': 'col-span-2 md:col-span-6',
        },
        options: {
            clr: 'col-start-1 md:col-start-1'
        }
    },
    defaultVariants: {
        width: '1',
    }
}) %}

{% set formAttr = {
    'data-action': 'turbo:submit-end->ferienpass--admin-edit#resetDirty live:saved->ferienpass--admin-edit#resetDirty'
} %}

{{ form_start(form, { attr: formAttr }) }}

          {% if not form.vars.valid %}

              <twig:Admin:Alert type="error" class="mt-4">

                  <strong class="font-semibold">Bitte beheben Sie die Fehler im Formular.</strong>

                  {{ form_errors(form) }}

              </twig:Admin:Alert>

          {% endif %}

<div class="space-y-6">

    <div>

        <div class="grid grid-cols-2 md:grid-cols-6 gap-6">

            {% for field in form.children|filter(f => f.vars['section']|default)|sort((a, b) => a.vars.order <=> b.vars.order) %}

                {% set width = field.vars['width']|default|split('|')[0]|default(null) %}
                {% set options = field.vars['width']|default|split('|')[1]|default(null) %}

                <div class="{{ grid.apply({width, options}) }}">
                    {{ form_row(field) }}
                </div>

            {% endfor %}

        </div>

    </div>


    {% if this is defined %}
        <twig:Admin:Edit:Footer
                :isDirty="formDirty|default(false)"
                :sections="sections|default([])"
                :section="section|default(null)"
                :params="this.getRouteParameters()"
                :editRoute="editRoute|default(null)"
                :viewRoute="viewRoute|default(null)"
        />
{% endif %}


</div>

{{ form_end(form) }}
