Ticket #11303: HiddenBooleanInput.diff
File HiddenBooleanInput.diff, 1.8 KB (added by , 15 years ago) |
---|
-
django/forms/fields.py
28 28 from django.utils.encoding import smart_unicode, smart_str 29 29 30 30 from util import ErrorList, ValidationError 31 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget31 from widgets import TextInput, PasswordInput, HiddenInput, HiddenBooleanInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget 32 32 33 33 __all__ = ( 34 34 'Field', 'CharField', 'IntegerField', … … 581 581 582 582 class BooleanField(Field): 583 583 widget = CheckboxInput 584 hidden_widget = HiddenBooleanInput 584 585 585 586 def clean(self, value): 586 587 """Returns a Python boolean object.""" -
django/forms/widgets.py
234 234 input_type = 'hidden' 235 235 is_hidden = True 236 236 237 class HiddenBooleanInput(HiddenInput): 238 """ 239 A widget that handles <input type="hidden"> for boolean data. 240 The only difference from the original hidden input is that 241 it will not place a "0" for False. 242 """ 243 def render(self, name, value, attrs=None): 244 if not value: value = None 245 return super(HiddenBooleanInput, self).render(name, value, attrs) 246 237 247 class MultipleHiddenInput(HiddenInput): 238 248 """ 239 249 A widget that handles <input type="hidden"> for fields that have a list