Skip to content

Set multipart enctype on the sample header form so file uploads persist#2960

Open
ramonski wants to merge 1 commit into
2.xfrom
2.x-fix-sampleheader-multipart
Open

Set multipart enctype on the sample header form so file uploads persist#2960
ramonski wants to merge 1 commit into
2.xfrom
2.x-fix-sampleheader-multipart

Conversation

@ramonski

Copy link
Copy Markdown
Contributor

Description of the issue/feature this PR addresses

Linked issue: -

The senaite-sampleheader-form template declares method="post" but no enctype="multipart/form-data". As a result the browser submits the value of any <input type="file"> rendered inside that form as a plain filename string instead of a real FileUpload object. The widget's process_form then receives a str, getattr(value, "filename", "") is "", the widget treats the upload as no-change (correctly, given the input), and the file is silently dropped on save.

This is straightforward to hit when an ExtFileField (or any AT widget that expects to read its upload from request.form) is added to AnalysisRequest via a schema extender and made visible in header_table. The form submit otherwise succeeds, so there is no error to point at — the file just never persists.

Current behavior before PR

File uploads from a FileField / ExtFileField rendered in the sample header table are silently dropped on save: request.form["<field>_file"] is the string \"my.pdf\", the widget short-circuits, and the field remains empty.

Desired behavior after PR is merged

Files posted from the sample header form arrive as FileUpload instances, the widget's process_form reads the upload, and the field persists — matching the behaviour of every other Plone form with file inputs (base_edit, AR Add, attachments).

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@ramonski ramonski requested a review from xispa June 22, 2026 14:24
The senaite-sampleheader-form declares method='post' without
enctype='multipart/form-data', so any AT FileField rendered
inline in the header table posts as a filename string instead of
a real FileUpload. The widget's process_form then sees a string,
finds no .filename attribute, and silently treats the field as
empty - the file disappears on save even though the rest of the
form submit succeeds.

Setting the enctype matches what every other Plone form with
file inputs does (base_edit, AR Add, attachments) and lets
custom widgets like ExtFileField extensions on AnalysisRequest
roundtrip through the sample header form correctly.
@ramonski ramonski added the Bug 🐞 Something is broken label Jun 22, 2026
@ramonski ramonski force-pushed the 2.x-fix-sampleheader-multipart branch from 9820f84 to 6192a3e Compare June 22, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug 🐞 Something is broken

Development

Successfully merging this pull request may close these issues.

1 participant