summaryrefslogtreecommitdiff
path: root/docs/topics/forms
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2023-02-12 13:24:50 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-15 10:26:31 +0100
commit3cc7a92189f45eab034661359e60ede4c88a6052 (patch)
treef83b7229ebf188db87464624e833fa36ffcff7f8 /docs/topics/forms
parent232b60a21b951bd16b8c95b34fcbcbf3ecd89fca (diff)
Refs #32339 -- Doc'd setting a form's template_name is recomended over using as_* methods.
Diffstat (limited to 'docs/topics/forms')
-rw-r--r--docs/topics/forms/index.txt40
1 files changed, 2 insertions, 38 deletions
diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt
index 9ca3509266..3d409f5f06 100644
--- a/docs/topics/forms/index.txt
+++ b/docs/topics/forms/index.txt
@@ -493,6 +493,8 @@ appropriately.
``<form>`` tags, or the form's ``submit`` control. You will have to provide
these yourself.
+.. _reusable-form-templates:
+
Reusable form templates
-----------------------
@@ -552,44 +554,6 @@ the :meth:`.Form.render`. Here's an example of this being used in a view::
See :ref:`ref-forms-api-outputting-html` for more details.
-Form rendering options
-----------------------
-
-There are other output options though for the ``<label>``/``<input>`` pairs:
-
-* ``{{ form.as_div }}`` will render them wrapped in ``<div>`` tags.
-
-* ``{{ form.as_table }}`` will render them as table cells wrapped in ``<tr>``
- tags.
-
-* ``{{ form.as_p }}`` will render them wrapped in ``<p>`` tags.
-
-* ``{{ form.as_ul }}`` will render them wrapped in ``<li>`` tags.
-
-Note that you'll have to provide the surrounding ``<table>`` or ``<ul>``
-elements yourself.
-
-Here's the output of ``{{ form.as_p }}`` for our ``ContactForm`` instance:
-
-.. code-block:: html+django
-
- <p><label for="id_subject">Subject:</label>
- <input id="id_subject" type="text" name="subject" maxlength="100" required></p>
- <p><label for="id_message">Message:</label>
- <textarea name="message" id="id_message" required></textarea></p>
- <p><label for="id_sender">Sender:</label>
- <input type="email" name="sender" id="id_sender" required></p>
- <p><label for="id_cc_myself">Cc myself:</label>
- <input type="checkbox" name="cc_myself" id="id_cc_myself"></p>
-
-Note that each form field has an ID attribute set to ``id_<field-name>``, which
-is referenced by the accompanying label tag. This is important in ensuring that
-forms are accessible to assistive technology such as screen reader software.
-You can also :ref:`customize the way in which labels and ids are generated
-<ref-forms-api-configuring-label>`.
-
-See :ref:`ref-forms-api-outputting-html` for more on this.
-
Rendering fields manually
-------------------------