Ticket #2116: CheckboxSelectMultipleField_add_ul_class.patch
File CheckboxSelectMultipleField_add_ul_class.patch, 1.1 KB (added by , 18 years ago) |
---|
-
django/forms/__init__.py
613 613 back into the single list that validators, renderers and save() expect. 614 614 """ 615 615 requires_data_list = True 616 def __init__(self, field_name, choices=None, validator_list=None):616 def __init__(self, field_name, choices=None, ul_class='', validator_list=None): 617 617 if validator_list is None: validator_list = [] 618 618 if choices is None: choices = [] 619 self.ul_class = ul_class 619 620 SelectMultipleField.__init__(self, field_name, choices, size=1, is_required=False, validator_list=validator_list) 620 621 621 622 def prepare(self, new_data): … … 628 629 new_data.setlist(self.field_name, data_list) 629 630 630 631 def render(self, data): 631 output = ['<ul >']632 output = ['<ul%s>' % (self.ul_class and ' class="%s"' % self.ul_class or '')] 632 633 str_data_list = map(str, data) # normalize to strings 633 634 for value, choice in self.choices: 634 635 checked_html = ''