diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 3c27f7e2c1..585e12cc18 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -258,11 +258,16 @@ class RadioSelect(Select): class CheckboxSelectMultiple(SelectMultiple): def render(self, name, value, attrs=None, choices=()): if value is None: value = [] + has_id = attrs and attrs.has_key('id') final_attrs = self.build_attrs(attrs, name=name) output = [u' +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'] + + Data for a MultipleChoiceField should be a list. QueryDict and MultiValueDict conveniently work with this. >>> data = {'name': 'Yesterday', 'composers': ['J', 'P']}