Code

Ticket #5104: checkboxinput.patch

File checkboxinput.patch, 712 bytes (added by SmileyChris, 7 years ago)
  • django/newforms/widgets.py

     
    153153            final_attrs['value'] = force_unicode(value) # Only add the 'value' attribute if a value is non-empty. 
    154154        return u'<input%s />' % flatatt(final_attrs) 
    155155 
     156    def value_from_datadict(self, data, name): 
     157        # A missing value returns False rather than None because it  
     158        # simply means the check box wasn't checked). 
     159        value = data.get(name, False) 
     160 
    156161class Select(Widget): 
    157162    def __init__(self, attrs=None, choices=()): 
    158163        self.attrs = attrs or {}