Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #2116 -- Added ul_class parameter to CheckboxSelectMultipleFiel…

…d. Thanks, Jorge Gajon

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3110 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a88e0ec5c682e455a1b71837b9bb40ed4ace5ae2 1 parent 3aa6b05
@adrianholovaty adrianholovaty authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 django/forms/__init__.py
View
5 django/forms/__init__.py
@@ -613,9 +613,10 @@ class CheckboxSelectMultipleField(SelectMultipleField):
back into the single list that validators, renderers and save() expect.
"""
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 choices is None: choices = []
+ self.ul_class = ul_class
SelectMultipleField.__init__(self, field_name, choices, size=1, is_required=False, validator_list=validator_list)
def prepare(self, new_data):
@@ -628,7 +629,7 @@ def prepare(self, new_data):
new_data.setlist(self.field_name, data_list)
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
for value, choice in self.choices:
checked_html = ''
Please sign in to comment.
Something went wrong with that request. Please try again.