Commit 18ea1c47 authored by Ramiro Morales's avatar Ramiro Morales
Browse files

Forms docs: More emphasis in 'id' value customizability.

parent 21c2bfdf
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -408,21 +408,27 @@ classes, as needed. The HTML will look something like::

.. _ref-forms-api-configuring-label:

Configuring HTML ``<label>`` tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Configuring form elements' HTML ``id`` attributes and ``<label>`` tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. attribute:: Form.auto_id

By default, the form rendering methods include:

* HTML ``id`` attributes on the form elements.

An HTML ``<label>`` tag designates which label text is associated with which
form element. This small enhancement makes forms more usable and more accessible
to assistive devices. It's always a good idea to use ``<label>`` tags.
* The corresponding ``<label>`` tags around the labels. An HTML ``<label>`` tag
  designates which label text is associated with which form element. This small
  enhancement makes forms more usable and more accessible to assistive devices.
  It's always a good idea to use ``<label>`` tags.

By default, the form rendering methods include HTML ``id`` attributes on the
form elements and corresponding ``<label>`` tags around the labels. The ``id``
attribute values are generated by prepending ``id_`` to the form field names.
This behavior is configurable, though, if you want to change the ``id``
convention or remove HTML ``id`` attributes and ``<label>`` tags entirely.
The ``id`` attribute values are generated by prepending ``id_`` to the form
field names.  This behavior is configurable, though, if you want to change the
``id`` convention or remove HTML ``id`` attributes and ``<label>`` tags
entirely.

Use the ``auto_id`` argument to the ``Form`` constructor to control the label
and ``id`` behavior. This argument must be ``True``, ``False`` or a string.
Use the ``auto_id`` argument to the ``Form`` constructor to control the ``id``
and label behavior. This argument must be ``True``, ``False`` or a string.

If ``auto_id`` is ``False``, then the form output will not include ``<label>``
tags nor ``id`` attributes::