mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #3312 -- CheckboxSelectMultiple no longer uses duplicate ID attributes for each checkbox
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4436 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
982a9443e1
commit
c0e01416b6
2 changed files with 17 additions and 2 deletions
|
|
@ -2149,6 +2149,16 @@ MultipleChoiceField can also be used with the CheckboxSelectMultiple widget.
|
|||
<li><label><input checked="checked" type="checkbox" name="composers" value="P" /> Paul McCartney</label></li>
|
||||
</ul>
|
||||
|
||||
Regarding auto_id, CheckboxSelectMultiple is a special case. Each checkbox
|
||||
gets a distinct ID, formed by appending an underscore plus the checkbox's
|
||||
zero-based index.
|
||||
>>> f = SongForm(auto_id='%s_id')
|
||||
>>> print f['composers']
|
||||
<ul>
|
||||
<li><label><input type="checkbox" name="composers" value="J" id="composers_id_0" /> John Lennon</label></li>
|
||||
<li><label><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li>
|
||||
</ul>
|
||||
|
||||
Data for a MultipleChoiceField should be a list. QueryDict and MultiValueDict
|
||||
conveniently work with this.
|
||||
>>> data = {'name': 'Yesterday', 'composers': ['J', 'P']}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue