mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #20684 -- Added support for HTML5 boolean attributes to form widgets.
This commit is contained in:
parent
684e8a941b
commit
e61d99d96d
4 changed files with 30 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -106,7 +106,8 @@ File Uploads
|
|||
Forms
|
||||
^^^^^
|
||||
|
||||
* ...
|
||||
* Form widgets now render attributes with a value of ``True`` or ``False``
|
||||
as HTML5 boolean attributes.
|
||||
|
||||
Internationalization
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue