Opened 12 years ago
Closed 12 years ago
#19581 closed Bug (fixed)
Duplicate IDs with CheckboxSelectMultiple if ID passed to constructor
Reported by: | lraucy | Owned by: | lraucy |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | CheckboxSelectMultiple ID |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When a CheckboxSelectMultiple widget is instantiated with attrs passed to the constructor, render() produces invalid HTML:
all the input tags use the same html ID.
Exemple:
from django.forms.widgets import CheckboxSelectMultiple print CheckboxSelectMultiple(attrs={'id': 'abc'}).render('letters', list('ac'), choices=zip(list('abc'), list('ABC')))
Result:
<ul> <li><label><input checked="checked" type="checkbox" id="abc" value="a" name="letters" /> A</label></li> <li><label><input type="checkbox" id="abc" value="b" name="letters" /> B</label></li> <li><label><input checked="checked" type="checkbox" id="abc" value="c" name="letters" /> C</label></li> </ul>
Change History (4)
comment:1 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 12 years ago
Has patch: | set |
---|---|
Status: | assigned → new |
comment:3 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
This is prob RFC but on my mobile so can't do a full verification, but looks good.
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Patch https://github.com/django/django/pull/626