From 859e3e5f848171d90eddc018ff18419faf20ea20 Mon Sep 17 00:00:00 2001 From: Bernard Siebens Date: Mon, 3 Aug 2026 21:37:04 +0200 Subject: [PATCH] Fix file uploads in modal forms: multi-file input rendering + enctype Two bugs, both invisible until the news photo upload modal exercised them: the shared field template didn't recognise a custom multi-file widget (it fell through to a plain, useless text input), and the modal form itself had no enctype="multipart/form-data" -- so even a correctly rendered file input would have posted filenames only, never content. --- controlpanel/templates/controlpanel/_modal_form.html | 5 +++-- controlpanel/templates/templatetags/field.html | 1 + controlpanel/templatetags/ui.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/controlpanel/templates/controlpanel/_modal_form.html b/controlpanel/templates/controlpanel/_modal_form.html index 12b879b..760a469 100644 --- a/controlpanel/templates/controlpanel/_modal_form.html +++ b/controlpanel/templates/controlpanel/_modal_form.html @@ -5,14 +5,15 @@ `action_url`. Included with `modal_id`, `title`, `form`, `action_url`, `submit_label` and `submit_icon`, plus an optional `blurb`. The submit button sits outside the form 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. + 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. {% endcomment %} {% trans "Save" as default_submit_label %}