Opened 15 months ago
Closed 15 months ago
#34837 closed New feature (wontfix)
CheckboxSelectMultiple.attrs should accept more than "id" and "class"
Reported by: | HarryKane | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In a Form I want to modify the widget of a field, like
"field": django.forms.CheckboxSelectMultiple( attrs={ "id": "my-id", "class": "foo" "hx-get": "/some/path/, "hx-target": "#target-id", "hx-trigger": "load", } )
but it just renders
<div id="my-id" class="foo">...</div>
instead of
<div id="my-id" class="foo" hx-get="...", hx-target="...", "hx-trigger="...">...</div>
The reason seams to be, that the django/forms/widets/multiple_input.html
renders only id
and class
{% with id=widget.attrs.id %}<div{% if id %} id="{{ id }}"{% endif %}{% if widget.attrs.class %} class="{{ widget.attrs.class }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
Note:
See TracTickets
for help on using tickets.
Hi Harry,
Thanks for the report, though new feature requests should be discussed in the Django forum first (Internals category) where it will reacher a wider audience: https://code.djangoproject.com/wiki/DevelopersMailingList
If a consensus is reached, please reopen this ticket with a link to the discussion 👍
Thanks!