Fixed #20684 -- Added support for HTML5 boolean attributes to form widgets.

This commit is contained in:
Loic Bistuer 2014-03-23 00:16:49 +07:00 committed by Tim Graham
parent 684e8a941b
commit e61d99d96d
4 changed files with 30 additions and 16 deletions

View file

@ -205,6 +205,19 @@ foundation for custom widgets.
>>> name.render('name', 'A name')
u'<input title="Your name" type="text" name="name" value="A name" size="10" />'
.. versionchanged:: 1.8
If you assign a value of ``True`` or ``False`` to an attribute,
it will be rendered as an HTML5 boolean attribute::
>>> name = forms.TextInput(attrs={'required': True})
>>> name.render('name', 'A name')
'<input name="name" type="text" value="A name" required />'
>>>
>>> name = forms.TextInput(attrs={'required': False})
>>> name.render('name', 'A name')
'<input name="name" type="text" value="A name" />'
.. method:: render(name, value, attrs=None)
Returns HTML for the widget, as a Unicode string. This method must be

View file

@ -106,7 +106,8 @@ File Uploads
Forms
^^^^^
* ...
* Form widgets now render attributes with a value of ``True`` or ``False``
as HTML5 boolean attributes.
Internationalization
^^^^^^^^^^^^^^^^^^^^