diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-07-21 22:05:17 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-04 19:16:54 -0400 |
| commit | 50e299dbfbbfd796e63e7e13b4566cf69d2c4acb (patch) | |
| tree | e099779317d600e23cdf45f2e7c0b5a1e69791d8 /docs/ref/forms | |
| parent | ebed9ee8d5e4268d9393261633b2c23cffd426fc (diff) | |
Fixed #26928 -- Changed forms' checked attribute to HTML5 boolean style.
Diffstat (limited to 'docs/ref/forms')
| -rw-r--r-- | docs/ref/forms/api.txt | 21 | ||||
| -rw-r--r-- | docs/ref/forms/widgets.txt | 4 |
2 files changed, 19 insertions, 6 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 9e9388344a..de66986e18 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -430,7 +430,7 @@ If the form is bound to data, the HTML output will include that data appropriately. For example, if a field is represented by an ``<input type="text">``, the data will be in the ``value`` attribute. If a field is represented by an ``<input type="checkbox">``, then that HTML will -include ``checked="checked"`` if appropriate:: +include ``checked`` if appropriate:: >>> data = {'subject': 'hello', ... 'message': 'Hi there', @@ -441,7 +441,12 @@ include ``checked="checked"`` if appropriate:: <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" value="hello" required /></td></tr> <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" value="Hi there" required /></td></tr> <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" value="foo@example.com" required /></td></tr> - <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" checked="checked" /></td></tr> + <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" checked /></td></tr> + +.. versionchanged:: 1.11 + + The ``checked`` attribute was changed to use HTML5 boolean syntax rather + than ``checked="checked"``. This default output is a two-column HTML table, with a ``<tr>`` for each field. Notice the following: @@ -471,6 +476,10 @@ Notice the following: attributes and ``<label>`` tags are included in the output by default, to follow best practices, but you can change that behavior. +* The output uses HTML5 syntax, targeting ``<!DOCTYPE html>``. For example, + it uses boolean attributes such as ``checked`` rather than the XHTML style + of ``checked='checked'``. + Although ``<table>`` output is the default output style when you ``print`` a form, other output styles are available. Each style is available as a method on a form object, and each rendering method returns a Unicode object. @@ -751,19 +760,19 @@ method you're using:: <tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" required /></td></tr> <tr><th>Message:</th><td><input type="text" name="message" value="Hi there" required /></td></tr> <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid email address.</li></ul><input type="email" name="sender" value="invalid email address" required /></td></tr> - <tr><th>Cc myself:</th><td><input checked="checked" type="checkbox" name="cc_myself" /></td></tr> + <tr><th>Cc myself:</th><td><input checked type="checkbox" name="cc_myself" /></td></tr> >>> print(f.as_ul()) <li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" required /></li> <li>Message: <input type="text" name="message" value="Hi there" required /></li> <li><ul class="errorlist"><li>Enter a valid email address.</li></ul>Sender: <input type="email" name="sender" value="invalid email address" required /></li> - <li>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></li> + <li>Cc myself: <input checked type="checkbox" name="cc_myself" /></li> >>> print(f.as_p()) <p><ul class="errorlist"><li>This field is required.</li></ul></p> <p>Subject: <input type="text" name="subject" maxlength="100" required /></p> <p>Message: <input type="text" name="message" value="Hi there" required /></p> <p><ul class="errorlist"><li>Enter a valid email address.</li></ul></p> <p>Sender: <input type="email" name="sender" value="invalid email address" required /></p> - <p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p> + <p>Cc myself: <input checked type="checkbox" name="cc_myself" /></p> .. _ref-forms-error-list-format: @@ -789,7 +798,7 @@ Python 2):: <p>Message: <input type="text" name="message" value="Hi there" required /></p> <div class="errorlist"><div class="error">Enter a valid email address.</div></div> <p>Sender: <input type="email" name="sender" value="invalid email address" required /></p> - <p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p> + <p>Cc myself: <input checked type="checkbox" name="cc_myself" /></p> More granular output ==================== diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index aae92a37c9..6af97469c9 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -11,6 +11,10 @@ A widget is Django's representation of an HTML input element. The widget handles the rendering of the HTML, and the extraction of data from a GET/POST dictionary that corresponds to the widget. +The HTML generated by the built-in widgets uses HTML5 syntax, targeting +``<!DOCTYPE html>``. For example, it uses boolean attributes such as ``checked`` +rather than the XHTML style of ``checked='checked'``. + .. tip:: Widgets should not be confused with the :doc:`form fields </ref/forms/fields>`. |
