feat: streamlined rendering of fields as static text in forms
This commit is contained in:
@@ -4,10 +4,16 @@
|
|||||||
{# Field is in form structure - render normally as form input #}
|
{# Field is in form structure - render normally as form input #}
|
||||||
{{ form_row(form[fieldName], options) }}
|
{{ form_row(form[fieldName], options) }}
|
||||||
{% elseif is_static_text(fieldName, bookingDto, participantIndex) %}
|
{% elseif is_static_text(fieldName, bookingDto, participantIndex) %}
|
||||||
{# Field excluded from form but should render as static text #}
|
{# Field excluded from form - render as static text in fieldset/table style #}
|
||||||
<div class="mb-1">
|
<div class="pb-4">
|
||||||
<label class="font-semibold block">{{ label }}</label>
|
<fieldset class="border border-primary-bg">
|
||||||
<div class="text-sm text-gray-600">{{ staticValue ?: '-' }}</div>
|
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">{{ label }}</legend>
|
||||||
|
<table class="w-full table-fixed border-collapse">
|
||||||
|
<tr>
|
||||||
|
<td class="border border-primary-bg p-2">{{ staticValue ?: '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{# If neither condition is true, don't render anything (truly hidden) #}
|
{# If neither condition is true, don't render anything (truly hidden) #}
|
||||||
@@ -169,7 +175,60 @@
|
|||||||
} %}
|
} %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Personal data section #}
|
{# Personal data and address section #}
|
||||||
|
{% set isPersonalDataStatic = is_static_text('firstName', bookingDto, participantIndex) %}
|
||||||
|
{% set isAddressStatic = is_static_text('address', bookingDto, participantIndex) %}
|
||||||
|
|
||||||
|
{% if isPersonalDataStatic and isAddressStatic %}
|
||||||
|
{# Both personal data and address are static - render in two-column grid with tables #}
|
||||||
|
{% set participant = form.vars.data.participant %}
|
||||||
|
{% set addressSource = (0 == participantIndex and bookingDto.booking) ? bookingDto.booking.applicant : bookingDto.participants[participantIndex] %}
|
||||||
|
{% set genderLabel = participant.gender == 'M' ? 'männlich' : (participant.gender == 'W' ? 'weiblich' : (participant.gender == 'D' ? 'divers' : null)) %}
|
||||||
|
|
||||||
|
<div class="grid lg:grid-cols-2 lg:gap-x-8 pb-4">
|
||||||
|
{# Personal data #}
|
||||||
|
<div class="pb-4 lg:pb-0">
|
||||||
|
<fieldset class="border border-primary-bg">
|
||||||
|
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">Persönliche Daten</legend>
|
||||||
|
<table class="w-full table-fixed border-collapse">
|
||||||
|
<tr>
|
||||||
|
<td class="border border-primary-bg p-2">
|
||||||
|
<strong>Name:</strong> {{ participant.firstName }} {{ participant.lastName }}<br>
|
||||||
|
<strong>Geburtsdatum:</strong> {{ participant.dateOfBirth ? participant.dateOfBirth|date('d.m.Y') : '-' }}<br>
|
||||||
|
<strong>Geschlecht:</strong> {{ genderLabel ?: '-' }}<br>
|
||||||
|
<strong>Nationalität:</strong> {{ participant.nationality ? participant.nationality|map_nationality : '-' }}<br>
|
||||||
|
<strong>E-Mail:</strong> {{ participant.email ?: '-' }}<br>
|
||||||
|
<strong>Telefon:</strong> {{ participant.mobile ?: '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Address #}
|
||||||
|
<div>
|
||||||
|
<fieldset class="border border-primary-bg">
|
||||||
|
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">Adresse</legend>
|
||||||
|
<table class="w-full table-fixed border-collapse">
|
||||||
|
<tr>
|
||||||
|
<td class="border border-primary-bg p-2">
|
||||||
|
{% if addressSource.address %}
|
||||||
|
{% if addressSource.address.street %}{{ addressSource.address.street }}<br>{% endif %}
|
||||||
|
{% if addressSource.address.postCode or addressSource.address.city %}
|
||||||
|
{{ addressSource.address.postCode }} {{ addressSource.address.city }}<br>
|
||||||
|
{% endif %}
|
||||||
|
{% if addressSource.address.country %}{{ addressSource.address.country|map_country }}{% endif %}
|
||||||
|
{% else %}
|
||||||
|
-
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{# Editable form fields for personal data #}
|
||||||
<div class="grid lg:grid-cols-2 lg:gap-x-8">
|
<div class="grid lg:grid-cols-2 lg:gap-x-8">
|
||||||
{{ macros.field_or_static(form, 'firstName', 'Vorname', form.vars.data.participant.firstName, bookingDto, participantIndex) }}
|
{{ macros.field_or_static(form, 'firstName', 'Vorname', form.vars.data.participant.firstName, bookingDto, participantIndex) }}
|
||||||
{{ macros.field_or_static(form, 'lastName', 'Nachname', form.vars.data.participant.lastName, bookingDto, participantIndex) }}
|
{{ macros.field_or_static(form, 'lastName', 'Nachname', form.vars.data.participant.lastName, bookingDto, participantIndex) }}
|
||||||
@@ -209,25 +268,7 @@
|
|||||||
{{ form_row(form.address.city) }}
|
{{ form_row(form.address.city) }}
|
||||||
{{ form_row(form.address.country) }}
|
{{ form_row(form.address.country) }}
|
||||||
</div>
|
</div>
|
||||||
{% elseif is_static_text('address', bookingDto, participantIndex) %}
|
|
||||||
{# Address excluded from form but should render as static text #}
|
|
||||||
{# For applicant (index 0), use booking.applicant.address which has full data from BPN #}
|
|
||||||
{# For other participants, use participants[index].address (may only have country in BPN response) #}
|
|
||||||
{% set addressSource = (0 == participantIndex and bookingDto.booking) ? bookingDto.booking.applicant : bookingDto.participants[participantIndex] %}
|
|
||||||
<div>
|
|
||||||
<label class="font-semibold mb-1 block">Adresse</label>
|
|
||||||
{% if addressSource.address %}
|
|
||||||
<div class="text-sm text-gray-600">
|
|
||||||
{% if addressSource.address.street %}{{ addressSource.address.street }}<br>{% endif %}
|
|
||||||
{% if addressSource.address.postCode or addressSource.address.city %}
|
|
||||||
{{ addressSource.address.postCode }} {{ addressSource.address.city }}<br>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if addressSource.address.country %}{{ addressSource.address.country|map_country }}{% endif %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="text-sm text-gray-600">-</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# Room assignment - hidden until date of birth is provided, or shown as static text in edit mode #}
|
{# Room assignment - hidden until date of birth is provided, or shown as static text in edit mode #}
|
||||||
|
|||||||
Reference in New Issue
Block a user