mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #9336. Changed CheckboxInput to render 'True' and 'False' input strings as checked or not instead of as a value attribute. Thanks, bthomas.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12556 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -295,6 +295,24 @@ attribute in the Form gets precedence.
|
||||
>>> print f['get_spam']
|
||||
<input checked="checked" type="checkbox" name="get_spam" />
|
||||
|
||||
'True' or 'true' should be rendered without a value attribute
|
||||
>>> f = SignupForm({'email': 'test@example.com', 'get_spam': 'True'}, auto_id=False)
|
||||
>>> print f['get_spam']
|
||||
<input checked="checked" type="checkbox" name="get_spam" />
|
||||
|
||||
>>> f = SignupForm({'email': 'test@example.com', 'get_spam': 'true'}, auto_id=False)
|
||||
>>> print f['get_spam']
|
||||
<input checked="checked" type="checkbox" name="get_spam" />
|
||||
|
||||
A value of 'False' or 'false' should be rendered unchecked
|
||||
>>> f = SignupForm({'email': 'test@example.com', 'get_spam': 'False'}, auto_id=False)
|
||||
>>> print f['get_spam']
|
||||
<input type="checkbox" name="get_spam" />
|
||||
|
||||
>>> f = SignupForm({'email': 'test@example.com', 'get_spam': 'false'}, auto_id=False)
|
||||
>>> print f['get_spam']
|
||||
<input type="checkbox" name="get_spam" />
|
||||
|
||||
Any Field can have a Widget class passed to its constructor:
|
||||
>>> class ContactForm(Form):
|
||||
... subject = CharField()
|
||||
|
||||
Reference in New Issue
Block a user