From 66dd51d75af3587647570da08df8a455109fe338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 30 Sep 2025 17:11:30 +0200 Subject: [PATCH] feat: improved form layout --- templates/booking/create_step_2.html.twig | 201 +++++++++++----------- 1 file changed, 105 insertions(+), 96 deletions(-) diff --git a/templates/booking/create_step_2.html.twig b/templates/booking/create_step_2.html.twig index 3c67349..f18e88f 100644 --- a/templates/booking/create_step_2.html.twig +++ b/templates/booking/create_step_2.html.twig @@ -1,5 +1,55 @@ {% extends 'layout.html.twig' %} +{# Local form theme override for consistent fieldset rendering #} +{% use 'forms.html.twig' %} + +{% block form_row %} + {%- if form.vars.expanded is defined and form.vars.expanded -%} + {# Expanded forms get fieldset wrapper #} +
+ + {{- form.vars.label -}} + + {{- form_widget(form, { + 'attr': attr|default({}) + }) -}} + {{- form_errors(form) -}} + {{- form_help(form) -}} +
+ {%- else -%} + {{- parent() -}} + {%- endif -%} +{% endblock %} + +{% import _self as macros %} + +{# Macro to render a field or placeholder with consistent fieldset structure #} +{% macro service_field(participant, fieldName, label, options = {}) %} + {% if participant[fieldName] is defined %} + {{ form_row(participant[fieldName], options) }} + {% else %} +
+ {{ label }} +
Nicht wählbar
+
+ {% endif %} +{% endmacro %} + +{# Specialized macro for checkbox fields (like rental insurance) that need manual fieldset wrapping #} +{% macro checkbox_field(participant, fieldName, label, options = {}) %} + {% if participant[fieldName] is defined %} +
+ {{ label }} + {{ form_row(participant[fieldName], options) }} +
+ {% else %} +
+ {{ label }} +
Nicht wählbar
+
+ {% endif %} +{% endmacro %} + {% block content %} {% include '_partials/_flashes.html.twig' %}

Neue Buchung

@@ -86,102 +136,61 @@ {% endif %}
- {% if participant.skiPass is defined %} - {{ form_row(participant.skiPass, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Skipass nicht wählbar -
- {% endif %} - {% if participant.courses is defined %} - {{ form_row(participant.courses, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Kurse nicht wählbar -
- {% endif %} - {% if participant.additionalServices is defined %} - {{ form_row(participant.additionalServices, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Zusatzleistungen nicht wählbar -
- {% endif %} - {% if participant.rentals is defined %} - {{ form_row(participant.rentals, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Leihmaterial nicht wählbar -
- {% endif %} - {% if participant.rentalInsurance is defined %} -
- - Leihmaterial-Versicherung - - {{ form_row(participant.rentalInsurance, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} -
- {% else %} -
- Leihmat.-Versicherung nicht wählbar -
- {% endif %} - {% if participant.board is defined %} - {{ form_row(participant.board, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Verpflegung nicht wählbar -
- {% endif %} - {% if participant.insurance is defined %} - {{ form_row(participant.insurance, { - 'attr': { - 'hx-trigger': 'change', - 'hx-post': path('app_booking_create_step_2_refresh'), - 'hx-swap': 'none' - } - }) }} - {% else %} -
- Versicherung nicht wählbar -
- {% endif %} + {{ _self.service_field(participant, 'skiPass', 'Skipass', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.service_field(participant, 'courses', 'Kurse', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.service_field(participant, 'additionalServices', 'Zusatzleistungen', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.service_field(participant, 'rentals', 'Leihmaterial', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.checkbox_field(participant, 'rentalInsurance', 'Leihmaterial-Versicherung', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.service_field(participant, 'board', 'Verpflegung', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }} + + {{ _self.service_field(participant, 'insurance', 'Reiseversicherung', { + 'attr': { + 'hx-trigger': 'change', + 'hx-post': path('app_booking_create_step_2_refresh'), + 'hx-swap': 'none' + } + }) }}
{# Transportation Services Section #}