From baab35b81f54551dd64d5a65dcc9c9e9d9d6c46e Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 15 Sep 2025 18:11:18 +0200 Subject: [PATCH] Items: Allow plugins to put forms above a formset (#5460) --- src/pretix/control/signals.py | 10 +++++++--- .../templates/pretixcontrol/item/index.html | 14 +++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/pretix/control/signals.py b/src/pretix/control/signals.py index fb5088accd..afae6a2a97 100644 --- a/src/pretix/control/signals.py +++ b/src/pretix/control/signals.py @@ -310,9 +310,13 @@ an instance of a form class that you bind yourself when appropriate. Your form w as part of the standard validation and rendering cycle and rendered using default bootstrap styles. It is advisable to set a prefix for your form to avoid clashes with other plugins. -Your forms may also have two special properties: ``template`` with a template that will be -included to render the form, and ``title``, which will be used as a headline. Your template -will be passed a ``form`` variable with your form. +Your forms may also have special properties: + +- ``template`` with a template that will be included to render the form. Your template will be passed a ``form`` + variable with your form. +- ``title``, which will be used as a headline. +- ``ìs_layouts = True``, if your form should be grouped with the ticket layout settings (mutually exclusive with setting ``title``). +- ``group_with_formset = True``, if your form should be grouped with a formset of the same ``title`` As with all event plugin signals, the ``sender`` keyword argument will contain the event. """ diff --git a/src/pretix/control/templates/pretixcontrol/item/index.html b/src/pretix/control/templates/pretixcontrol/item/index.html index 6aa7124362..e4678ab9fe 100644 --- a/src/pretix/control/templates/pretixcontrol/item/index.html +++ b/src/pretix/control/templates/pretixcontrol/item/index.html @@ -177,6 +177,18 @@ {% for v in formsets.values %}
{{ v.title }} + + {% for f in plugin_forms %} + {% if f.group_with_formset and f.title == v.title %} + {% if f.template and not "template" in f.fields %} + {% include f.template with form=f %} + {% else %} + {% bootstrap_form f layout="control" %} + {% endif %} +
+ {% endif %} + {% endfor %} + {% include v.template with formset=v %}
{% endfor %} @@ -276,7 +288,7 @@ {% endfor %} {% for f in plugin_forms %} - {% if not f.is_layouts and f.title %} + {% if not f.is_layouts and not f.group_with_formset and f.title %}
{{ f.title }} {% if f.template and not "template" in f.fields %}