mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #7753: clean NullBooleanField correctly when using HiddenInput. Thanks to julien and ElliottM.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8661 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
938f7ea913
commit
b99cc935eb
2 changed files with 26 additions and 1 deletions
|
|
@ -1091,6 +1091,20 @@ False
|
|||
>>> f.clean('3')
|
||||
>>> f.clean('hello')
|
||||
|
||||
# Make sure that the internal value is preserved if using HiddenInput (#7753)
|
||||
>>> class HiddenNullBooleanForm(Form):
|
||||
... hidden_nullbool1 = NullBooleanField(widget=HiddenInput, initial=True)
|
||||
... hidden_nullbool2 = NullBooleanField(widget=HiddenInput, initial=False)
|
||||
>>> f = HiddenNullBooleanForm()
|
||||
>>> print f
|
||||
<input type="hidden" name="hidden_nullbool1" value="True" id="id_hidden_nullbool1" /><input type="hidden" name="hidden_nullbool2" value="False" id="id_hidden_nullbool2" />
|
||||
>>> f = HiddenNullBooleanForm({ 'hidden_nullbool1': 'True', 'hidden_nullbool2': 'False' })
|
||||
>>> f.full_clean()
|
||||
>>> f.cleaned_data['hidden_nullbool1']
|
||||
True
|
||||
>>> f.cleaned_data['hidden_nullbool2']
|
||||
False
|
||||
|
||||
# MultipleChoiceField #########################################################
|
||||
|
||||
>>> f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue