feat: improved validation error rendering of booking form
This commit is contained in:
@@ -4,8 +4,19 @@
|
||||
{% include '_partials/_flashes.html.twig' %}
|
||||
{{ form_start(form) }}
|
||||
{% if not form.vars.valid %}
|
||||
{% set messages = form.vars.errors|map(error => error.message) %}
|
||||
{% include '_partials/_alert.html.twig' with { 'level': 'error', 'title': 'Die Buchung konnte nicht aktualisiert werden', 'messages': messages } %}
|
||||
{% include '_partials/_alert.html.twig' with { 'level': 'error', 'title': 'Die Buchung konnte nicht aktualisiert werden' } %}
|
||||
{% for child in form.participants.children %}
|
||||
{% if not child.vars.valid %}
|
||||
{% set participant = child.vars.data %}
|
||||
{% set messages = [] %}
|
||||
{% for field in child.children %}
|
||||
{% for error in field.vars.errors %}
|
||||
{% set messages = messages|merge([field.vars.label ~ ': ' ~ error.message]) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% include '_partials/_alert.html.twig' with { 'level': 'error', 'title': 'Teilnehmer:in ' ~ participant.index ~ ':' ~ participant.firstName ~ participant.lastName, 'messages': messages } %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div class="flex flex-col space-y-8 pb-8" {{ stimulus_controller('booking', { 'availabilities': availabilities.items }) }} {{ stimulus_controller('iframe', { 'offsetTop': 100 }) }}>
|
||||
<div class="p-8 border border-gray-300 rounded-md"
|
||||
@@ -103,16 +114,16 @@
|
||||
</div>
|
||||
</div>
|
||||
{% for child in form.participants %}
|
||||
<div>
|
||||
{% set participant = child.vars.data %}
|
||||
{% set participant = child.vars.data %}
|
||||
<div id="participant-{{ participant.index }}">
|
||||
{% if participant.status == 'S' %}
|
||||
{% do child.setRendered %}
|
||||
{% endif %}
|
||||
<div class="{{ html_classes('p-8 border rounded-md mb-4', { 'border-gray-300': child.vars.valid, 'border-red-500': not child.vars.valid }) }}" {{ stimulus_controller('toggle', {'open': child.vars.valid == false}, { 'closed': 'hidden' }) }}>
|
||||
<div class="{{ html_classes('p-8 border rounded-md mb-4', { 'border-gray-300': child.vars.valid, 'border-red-700': not child.vars.valid }) }}" {{ stimulus_controller('toggle', {'open': child.vars.valid == false}, { 'closed': 'hidden' }) }}>
|
||||
<div role="button" class="flex items-center justify-between" {{ stimulus_action('toggle', 'toggle', 'click') }}>
|
||||
<div class="flex items-center space-x-4">
|
||||
<span class="text-2xl leading-none font-semibold">Teilnehmer:in {{ participant.index }}: {{ participant.firstName }} {{ participant.lastName }}</span>
|
||||
{% if participant.status == 'S' %} <span class="inline-block px-2 py-1 text-xs bg-red-500 text-white">storniert</span>{% endif %}
|
||||
{% if participant.status == 'S' %} <span class="inline-block px-2 py-1 text-xs bg-red-700 text-white">storniert</span>{% endif %}
|
||||
</div>
|
||||
<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') }}>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
||||
|
||||
Reference in New Issue
Block a user