mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-07 16:10:15 +02:00
feat: replace fetch-based modal forms with Turbo Frames (#181)
Enable @hotwired/turbo with Drive explicitly disabled, then migrate the bo--modal-form Stimulus controller (custom fetch + X-Modal-Request pattern) to a thin bo--modal controller that lets Turbo handle HTTP and DOM swap. Adds frame templates for quiz questions and bank questions; controllers now detect Turbo-Frame header instead of X-Modal-Request.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
{% import 'backoffice/partials/answer_row.html.twig' as macros %}
|
||||
|
||||
<turbo-frame id="bank-question-modal-frame">
|
||||
{{ form_start(form, {attr: {novalidate: 'novalidate'}}) }}
|
||||
<div class="modal-body">
|
||||
{{ form_row(form.question) }}
|
||||
{{ form_row(form.reusable) }}
|
||||
{{ form_row(form.labels) }}
|
||||
<div data-controller="bo--form-collection"
|
||||
data-bo--form-collection-prototype-value="{{ macros.answer_row(form.answers.vars.prototype)|e('html_attr') }}">
|
||||
{{ form_label(form.answers) }}
|
||||
{{ form_errors(form.answers) }}
|
||||
<div data-bo--form-collection-target="collection">
|
||||
{% for answerForm in form.answers %}
|
||||
{{ macros.answer_row(answerForm) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% do form.answers.setRendered %}
|
||||
<div class="d-flex gap-2 mb-3">
|
||||
<button type="button" class="btn btn-sm btn-outline-primary"
|
||||
data-action="bo--form-collection#addItem">{{ 'Add answer'|trans }}</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary"
|
||||
data-action="bo--form-collection#sortAlphabetically">{{ 'Sort A–Z'|trans }}</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary"
|
||||
data-action="bo--form-collection#randomize">{{ 'Randomize'|trans }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ 'Cancel'|trans }}</button>
|
||||
{{ form_widget(form.save, {attr: {class: 'btn btn-primary'}}) }}
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
</turbo-frame>
|
||||
Reference in New Issue
Block a user