fix: adapt changes in create mode for edit mode, cleanup
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
{% import _self as macros %}
|
||||
|
||||
{# Macro to render a form field or static value #}
|
||||
{% macro field_or_static(form, fieldName, label, staticValue, options = {}) %}
|
||||
{% if form[fieldName] is defined %}
|
||||
{{ form_row(form[fieldName], options) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">{{ label }}</label>
|
||||
<div class="text-sm text-gray-600">{{ staticValue ?: '-' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{# Macro to render a field or placeholder with consistent fieldset structure #}
|
||||
{% macro service_field(form, fieldName, label, options = {}, undefinedLabel = 'Nicht wählbar') %}
|
||||
{% if form[fieldName] is defined %}
|
||||
@@ -46,88 +58,34 @@
|
||||
<div id="participant-form" class="space-y-4">
|
||||
{# Personal data section #}
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
{% if form.firstName is defined %}
|
||||
{{ form_row(form.firstName) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Vorname</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.firstName }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ macros.field_or_static(form, 'firstName', 'Vorname', form.vars.data.participant.firstName) }}
|
||||
{{ macros.field_or_static(form, 'lastName', 'Nachname', form.vars.data.participant.lastName) }}
|
||||
|
||||
{% if form.lastName is defined %}
|
||||
{{ form_row(form.lastName) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Nachname</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.lastName }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if form.dateOfBirth is defined %}
|
||||
{{ form_row(form.dateOfBirth, {
|
||||
{{ macros.field_or_static(
|
||||
form,
|
||||
'dateOfBirth',
|
||||
'Geburtsdatum',
|
||||
form.vars.data.participant.dateOfBirth ? form.vars.data.participant.dateOfBirth|date('d.m.Y') : null,
|
||||
{
|
||||
'attr': {
|
||||
'hx-trigger': 'change',
|
||||
'hx-post': path(refreshRouteName, refreshRouteParams|default({index: participantIndex})),
|
||||
'hx-target': '#main-content',
|
||||
'hx-swap': 'innerHTML'
|
||||
}
|
||||
}) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Geburtsdatum</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.dateOfBirth ? form.vars.data.participant.dateOfBirth|date('d.m.Y') : '-' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
}
|
||||
) }}
|
||||
|
||||
{% if form.gender is defined %}
|
||||
{{ form_row(form.gender) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Geschlecht</label>
|
||||
<div class="text-sm text-gray-600">
|
||||
{% if form.vars.data.participant.gender == 'M' %}
|
||||
männlich
|
||||
{% elseif form.vars.data.participant.gender == 'W' %}
|
||||
weiblich
|
||||
{% elseif form.vars.data.participant.gender == 'D' %}
|
||||
divers
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% set genderLabel = form.vars.data.participant.gender == 'M' ? 'männlich' : (form.vars.data.participant.gender == 'W' ? 'weiblich' : (form.vars.data.participant.gender == 'D' ? 'divers' : null)) %}
|
||||
{{ macros.field_or_static(form, 'gender', 'Geschlecht', genderLabel) }}
|
||||
|
||||
{% if form.nationality is defined %}
|
||||
{{ form_row(form.nationality) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Nationalität</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.nationality ?: '-' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ macros.field_or_static(form, 'nationality', 'Nationalität', form.vars.data.participant.nationality) }}
|
||||
</div>
|
||||
|
||||
{# Contact information #}
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
{% if form.email is defined %}
|
||||
{{ form_row(form.email) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">E-Mail</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.email }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if form.mobile is defined %}
|
||||
{{ form_row(form.mobile) }}
|
||||
{% else %}
|
||||
<div>
|
||||
<label class="font-semibold mb-1 block">Telefon (mobil)</label>
|
||||
<div class="text-sm text-gray-600">{{ form.vars.data.participant.mobile ?: '-' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ macros.field_or_static(form, 'email', 'E-Mail', form.vars.data.participant.email) }}
|
||||
{{ macros.field_or_static(form, 'mobile', 'Telefon (mobil)', form.vars.data.participant.mobile) }}
|
||||
</div>
|
||||
|
||||
{# Address #}
|
||||
|
||||
Reference in New Issue
Block a user