From c2a4380b704703430d9f88db6768b0d0916abed0 Mon Sep 17 00:00:00 2001 From: Bernard Siebens Date: Sat, 8 Aug 2026 19:01:14 +0200 Subject: [PATCH] Lay the plan modal out in two columns instead of one tall one PlanForm grew to seven fields with the billing rework, three of them short day counts, and the modal ran off the bottom of the screen. _modal_form.html gains two optional knobs -- box_class to widen the box, two_columns to grid the fields -- so only the plan create/edit modals opt in and every other modal renders exactly as before. Textareas and file inputs still span the full width; below `sm` it stays single-column, since two columns of form fields on a phone is worse than a long scroll. PlanForm's field order is chosen to suit that grid: pairing name with duration and the two day-counts with each other fills every row rather than leaving half of one empty next to the full-width description. Rebuilt static/css/app.css (unminified, matching how it is committed) to pick up the new grid utilities. --- controlpanel/forms.py | 12 +++- .../templates/controlpanel/_form_fields.html | 18 ++++-- .../templates/controlpanel/_modal_form.html | 7 ++- .../templates/controlpanel/billing.html | 4 +- static/css/app.css | 63 +++++++++++++++++++ 5 files changed, 95 insertions(+), 9 deletions(-) diff --git a/controlpanel/forms.py b/controlpanel/forms.py index 4ebabe7..60d822a 100644 --- a/controlpanel/forms.py +++ b/controlpanel/forms.py @@ -83,9 +83,19 @@ class FlagForm(forms.ModelForm): class PlanForm(forms.ModelForm): + """Field order is chosen for the two-column modal (see _form_fields.html): description + spans both columns, so pairing name with duration and the two day-counts with each other + fills every row instead of leaving half of one empty. + + name | duration_months + description ....................... (spans both) + renewal_lead_days | grace_days + is_trial | is_active + """ + class Meta: model = Plan - fields = ["name", "description", "duration_months", "renewal_lead_days", "grace_days", "is_trial", "is_active"] + fields = ["name", "duration_months", "description", "renewal_lead_days", "grace_days", "is_trial", "is_active"] class PlanPriceForm(forms.ModelForm): diff --git a/controlpanel/templates/controlpanel/_form_fields.html b/controlpanel/templates/controlpanel/_form_fields.html index 75b4c70..d592f3c 100644 --- a/controlpanel/templates/controlpanel/_form_fields.html +++ b/controlpanel/templates/controlpanel/_form_fields.html @@ -4,14 +4,22 @@ The field loop every card-form and modal-form wrapper shares: label, daisyUI-styled widget, help text, errors — with checkboxes laid out label-beside-input instead of label-above. Included with `form`. + + Pass `two_columns` to lay the fields out in two columns instead of one — for a form with + several short fields (a handful of day counts, say) that would otherwise make a modal + taller than the screen. Textareas and file inputs always span the full width regardless: + half a row is not enough to type a description into. Single column below `sm`, since two + columns of form fields on a phone is worse than a long scroll. {% endcomment %} {% for error in form.non_field_errors %}
{{ error }}
{% endfor %} -{% for field in form %} -
- {% form_field field %} -
-{% endfor %} +
+ {% for field in form %} +
+ {% form_field field %} +
+ {% endfor %} +
diff --git a/controlpanel/templates/controlpanel/_modal_form.html b/controlpanel/templates/controlpanel/_modal_form.html index 9b545a1..414c582 100644 --- a/controlpanel/templates/controlpanel/_modal_form.html +++ b/controlpanel/templates/controlpanel/_modal_form.html @@ -7,10 +7,15 @@ tag (linked via the `form` attribute) so it can share the `modal-action` row with the dialog-closing Cancel button without nesting one
inside another. `enctype` is always multipart -- harmless for a form with no file field, required for one that has. + + Two optional knobs for a form with a lot of fields, which would otherwise run off the + bottom of the screen: `box_class` widens the box (e.g. "max-w-2xl"), and `two_columns` + lays the fields out in two columns -- growing sideways rather than downwards. They are + meant to be used together; widening alone just makes a tall modal wide as well. {% endcomment %} {% trans "Save" as default_submit_label %} -