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 %} -