wip: collapsible forms

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent d205cd09ef
commit 8da77ee13b
+40 -30
View File
@@ -12,36 +12,46 @@
{% block participants_form %} {% block participants_form %}
<div id="participants-form" class="space-y-8 pb-8"{% if htmx_oob_swap is defined and htmx_oob_swap %} hx-swap-oob="true"{% endif %}> <div id="participants-form" class="space-y-8 pb-8"{% if htmx_oob_swap is defined and htmx_oob_swap %} hx-swap-oob="true"{% endif %}>
{% for participant in form.participants %} {% for participant in form.participants %}
<fieldset class="border rounded-md p-8 pt-4"> {% set participantDataValid = participant.vars.valid %}
<legend class="font-bold text-xl px-2"> <div class="{{ html_classes('border rounded px-4 py-2', { 'border-gray-300': participantDataValid, 'border-red-700': not participantDataValid }) }}" {{ stimulus_controller('toggle', {'open': participant.vars.valid == false}, { 'closed': 'hidden' }) }}>
Teilnehmer:in {{ loop.index }} <fieldset>
</legend> <legend class="w-full flex items-center justify-between">
<div class="grid grid-cols-2 gap-4 pb-4"> <span class="font-bold text-xl">Teilnehmer:in {{ loop.index }}</span>
{{ form_row(participant.firstName) }} <button type="button" tabindex="0" {{ stimulus_action('toggle', 'toggle') }}>
{{ form_row(participant.lastName) }} <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6" {{ stimulus_target('toggle', 'icon') }}>
{{ form_row(participant.dateOfBirth) }} <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
{{ form_row(participant.gender) }} </svg>
{{ form_row(participant.nationality) }} </button>
</div> </legend>
<div class="grid grid-cols-2 gap-4"> <div class="hidden py-4" {{ stimulus_target('toggle', 'toggle') }}>
{{ form_row(participant.email) }} <div class="grid grid-cols-2 gap-4 pb-4">
{{ form_row(participant.mobile) }} {{ form_row(participant.firstName) }}
</div> {{ form_row(participant.lastName) }}
<div class="grid grid-cols-2 gap-4"> {{ form_row(participant.dateOfBirth) }}
{{ form_row(participant.bodyDimensions.height) }} {{ form_row(participant.gender) }}
{{ form_row(participant.bodyDimensions.shoeSize) }} {{ form_row(participant.nationality) }}
{{ form_row(participant.bodyDimensions.weight) }} </div>
</div> <div class="grid grid-cols-2 gap-4">
<div class="grid grid-cols-1 gap-4 pt-4"> {{ form_row(participant.email) }}
{# hx-swap="none" tells HTMX not to do a normal swap, as OOB will handle it #} {{ form_row(participant.mobile) }}
{{ form_row(participant.assignedRoomId, { </div>
'attr': { <div class="grid grid-cols-2 gap-4">
'hx-post': path('app_booking_create_step_2_refresh'), {{ form_row(participant.bodyDimensions.height) }}
'hx-swap': 'none' {{ form_row(participant.bodyDimensions.shoeSize) }}
} {{ form_row(participant.bodyDimensions.weight) }}
}) }} </div>
</div> <div class="grid grid-cols-1 gap-4 pt-4">
</fieldset> {# hx-swap="none" tells HTMX not to do a normal swap, as OOB will handle it #}
{{ form_row(participant.assignedRoomId, {
'attr': {
'hx-post': path('app_booking_create_step_2_refresh'),
'hx-swap': 'none'
}
}) }}
</div>
</div>
</fieldset>
</div>
{% endfor %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}