#27487: ModelAdmin.formfield_overrides on ManyToManyField isn't compatible with
CheckboxSelectMultiple
-------------------------------------+-------------------------------------
Reporter: nrogers64 | Owner: Adonys
Type: | Alea Boffill
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adonys Alea Boffill):
* needs_better_patch: 1 => 0
Comment:
Going back to the point about this ticket, and following the suggestion of
that comment [https://code.djangoproject.com/ticket/27487#comment:5], I
implemented a new solution for this problem, this time using `template-
base widget rendering` recently merged to master.
This problem occur when you override the defaults `Select` and
`SelectMultiple` widgets in the admin by `RadioSelect` or
`CheckboxSelectMultiple` respectively, and you need to add a new object of
the relationship. Both widgets are rendered as `UL` HTML list, and there
are not `JavaScript` support for that in `RelatedObjectLookups.js`. Every
time when you add a new object of the relationship, you need to refresh
the page to update the list with the added object.
I added support for these widgets in `RelatedObjectLookups.js`. To fix
that problem I added two attributes to the `UL` list in
`multiple_input.html`, both attributes will have "true" or "false" as
possibles values and are the following:
* `data-wrap-label`: Is "true" if the inputs of the list are wrapped into
a label.
* `data-multiple`: Is "true" if is a multiple select.
With that information I can handle the behavior of to add a new object of
the relationship using `RadioSelect` or `CheckboxSelectMultiple` as
widget.
To be sure of the correct operation, I added `JavaScript` and `Selenium`
tests, the rest of the tests runs fine.
I will add a new patch, but if necessary I can make a Pull Request.
--
Ticket URL: <https://code.djangoproject.com/ticket/27487#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.443bb5e72b2a93ac76e81d37cd3dc924%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.