feat: guard to prevent premature form submissions while uploading

This commit is contained in:
Björn Fromme
2026-03-15 12:42:28 +01:00
parent 0652ca9f8b
commit 923e880056
11 changed files with 68 additions and 20 deletions
+3 -2
View File
@@ -15,7 +15,8 @@
{% endmacro %}
{% block content %}
{{ form_start(form) }}
{% set formAttr = stimulus_controller('form-upload-guard')|stimulus_action('form-upload-guard', 'guard', 'submit') %}
{{ form_start(form, { 'attr': formAttr.toArray() }) }}
<div {{ stimulus_controller('tabs', {}, { 'buttonActive': 'bg-gray-50' }) }}>
<div class="grid lg:grid-cols-3 gap-y-8 lg:gap-y-0 lg:gap-x-16">
@@ -167,7 +168,7 @@
} %}
</div>
<button type="submit" class="btn">
<button type="submit" class="btn" {{ stimulus_target('form-upload-guard', 'submit') }}>
Aktualisieren
</button>
@@ -3,7 +3,8 @@
{% block title %}Lizenz hinzufügen{% endblock %}
{% block content %}
{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' } }) }}
{% set formAttr = stimulus_controller('form-upload-guard')|stimulus_action('form-upload-guard', 'guard', 'submit') %}
{{ form_start(form, { 'attr': { 'hx-post': app.request.uri, 'hx-target': '#htmx-modal', 'hx-swap': 'outerHTML' }|merge(formAttr.toArray()) }) }}
{% if not form.vars.valid %}
<div class="border border-red-500 rounded-md p-4 text-red-500 mb-4">
{% include '_partials/_form_errors.html.twig' with { 'form': form } %}
@@ -23,7 +24,7 @@
} %}
</div>
</div>
<button type="submit" class="btn">
<button type="submit" class="btn" {{ stimulus_target('form-upload-guard', 'submit') }}>
Speichern
</button>
{{ form_rest(form) }}