Ticket #2640: checkboxfield.patch
File checkboxfield.patch, 1.1 KB (added by , 18 years ago) |
---|
-
mytrunk/django/forms/__init__.py
434 434 (self.get_id(), self.field_name, escape(data)) 435 435 436 436 class CheckboxField(FormField): 437 def __init__(self, field_name, checked_by_default=False, validator_list=None ):437 def __init__(self, field_name, checked_by_default=False, validator_list=None,is_required=True): 438 438 if validator_list is None: validator_list = [] 439 439 self.field_name = field_name 440 440 self.checked_by_default = checked_by_default 441 self.is_required = False # because the validator looks for these441 self.is_required = is_required 442 442 self.validator_list = validator_list[:] 443 443 444 444 def render(self, data): … … 451 451 452 452 def html2python(data): 453 453 "Convert value from browser ('on' or '') to a Python boolean" 454 if data == 'on': 455 return True 456 return False 454 return True 457 455 html2python = staticmethod(html2python) 458 456 459 457 class SelectField(FormField):