Admin form submission via enter will incorrectly select all items from a ToManyField that uses a horizontal display instead of saving the form
In Django 5.2, when submitting a form by using the enter button while a input field is active, all items from a many to many list will be selected instead of saving the form. The field must be using the horizontal display via the filter_horizontal for this to happen. If the many to many field is not on the page it will save as expected.
This seems to be happening because the "Choose all X" button does not specify type="button" so it defaults to submit instead.
I believe this is a regression from ticket #34619 where four links were changed to buttons without specifying the type.
Commit: https://github.com/django/django/commit/857b1048d53ebf5fc5581c110e85c212b81ca83a#diff-3c2966b7041905eb8758311f5fedee0454575617ae55cfc7d0e3cc9d03c6671eR70
When I changed the type on all of those buttons to type="button" the page worked as expected.
Change History
(9)
Has patch: |
set
|
Owner: |
set to Blayze
|
Status: |
new → assigned
|
Triage Stage: |
Unreviewed → Accepted
|
Severity: |
Normal → Release blocker
|
Needs documentation: |
set
|
Needs tests: |
set
|
Needs documentation: |
unset
|
Needs tests: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
I created a small patch for this issue since it was a simple fix. Let me know if you would like anything changed.
https://github.com/django/django/pull/19510