Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Don't submit absent forms even when they have false_values children#64334

Merged
nicolas-grekas merged 1 commit into
symfony:8.1symfony/symfony:8.1from
hlecorche:fix-form-handle-missing-data-optionhlecorche/symfony:fix-form-handle-missing-data-optionCopy head branch name to clipboard
May 23, 2026
Merged

[Form] Don't submit absent forms even when they have false_values children#64334
nicolas-grekas merged 1 commit into
symfony:8.1symfony/symfony:8.1from
hlecorche:fix-form-handle-missing-data-optionhlecorche/symfony:fix-form-handle-missing-data-optionCopy head branch name to clipboard

Conversation

@hlecorche
Copy link
Copy Markdown
Contributor

@hlecorche hlecorche commented May 22, 2026

Q A
Branch? 8.1
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #64315
License MIT

Fix a regression introduced in #45081 (8.1): MissingDataHandler was called before the "form absent from request" guard, so for compound forms with false_values-aware children (expanded multiple ChoiceType, CheckboxType, ...) the handler synthesised values for the missing children, masking the "form absent" condition and causing the form to be submitted on any unrelated POST to the same endpoint.

The fix moves the early-return guard before MissingDataHandler::handle() in both the GET and request-body branches of HttpFoundationRequestHandler and NativeRequestHandler, so an entirely absent form is never processed. The legitimate false_values synthesis for missing children of a submitted form (e.g. all-unchecked checkboxes inside a form whose key is in the request body) is preserved.

…ldren

In 8.1, symfony#45081 made the request handlers call MissingDataHandler before
checking whether the form was actually present in the request. For
compound forms with false_values-aware children (expanded multiple
ChoiceType, CheckboxType, ...), the handler synthesises values for the
missing children, masking the "form absent" condition and causing the
form to be submitted on any unrelated POST to the same endpoint.

Move the early-return guard before MissingDataHandler::handle() so an
absent form is never processed.

Fixes symfony#64315.
@nicolas-grekas nicolas-grekas changed the title [Form] Add handle_missing_data option to opt into MissingDataHandler for absent forms [Form] Don't submit absent forms even when they have false_values children May 23, 2026
@nicolas-grekas nicolas-grekas force-pushed the fix-form-handle-missing-data-option branch from f512151 to bf2d2ec Compare May 23, 2026 15:51
Copy link
Copy Markdown
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation updated, no need for an new option (the use case where only checkboxes are in the form doesn't need to be supported.)

@nicolas-grekas
Copy link
Copy Markdown
Member

Thank you @hlecorche.

@nicolas-grekas nicolas-grekas merged commit 89d419a into symfony:8.1 May 23, 2026
5 of 12 checks passed
@fabpot fabpot mentioned this pull request May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Form] MissingDataHandler causes spurious form submission when form is absent from POST request body

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.