Fixed #2116 -- Added ul_class parameter to CheckboxSelectMultipleField. Thanks, Jorge Gajon
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3110 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3aa6b0556f
commit
a88e0ec5c6
|
@ -613,9 +613,10 @@ class CheckboxSelectMultipleField(SelectMultipleField):
|
||||||
back into the single list that validators, renderers and save() expect.
|
back into the single list that validators, renderers and save() expect.
|
||||||
"""
|
"""
|
||||||
requires_data_list = True
|
requires_data_list = True
|
||||||
def __init__(self, field_name, choices=None, validator_list=None):
|
def __init__(self, field_name, choices=None, ul_class='', validator_list=None):
|
||||||
if validator_list is None: validator_list = []
|
if validator_list is None: validator_list = []
|
||||||
if choices is None: choices = []
|
if choices is None: choices = []
|
||||||
|
self.ul_class = ul_class
|
||||||
SelectMultipleField.__init__(self, field_name, choices, size=1, is_required=False, validator_list=validator_list)
|
SelectMultipleField.__init__(self, field_name, choices, size=1, is_required=False, validator_list=validator_list)
|
||||||
|
|
||||||
def prepare(self, new_data):
|
def prepare(self, new_data):
|
||||||
|
@ -628,7 +629,7 @@ class CheckboxSelectMultipleField(SelectMultipleField):
|
||||||
new_data.setlist(self.field_name, data_list)
|
new_data.setlist(self.field_name, data_list)
|
||||||
|
|
||||||
def render(self, data):
|
def render(self, data):
|
||||||
output = ['<ul>']
|
output = ['<ul%s>' % (self.ul_class and ' class="%s"' % self.ul_class or '')]
|
||||||
str_data_list = map(str, data) # normalize to strings
|
str_data_list = map(str, data) # normalize to strings
|
||||||
for value, choice in self.choices:
|
for value, choice in self.choices:
|
||||||
checked_html = ''
|
checked_html = ''
|
||||||
|
|
Loading…
Reference in New Issue