summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2011-12-07 23:08:27 +0000
committerAdrian Holovaty <adrian@holovaty.com>2011-12-07 23:08:27 +0000
commit08bec4fbc10ca5638ad22f20a753ec5e8d92eb0e (patch)
tree05bde9737e73fa887ccf8e6ce524007557a2ea35 /docs/ref
parent0920165bc26bd55131462befc234ce7993a744ba (diff)
Changed BoundField.subwidgets() to return SubWidget objects instead of rendered strings. This means we can access individual radio buttons' properties in the template (see new docs)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17175 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/forms/widgets.txt37
1 files changed, 35 insertions, 2 deletions
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index b657be4c53..ac110c2ee8 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -386,8 +386,41 @@ commonly used groups of widgets:
<label><input type="radio" name="beatles" value="ringo" /> Ringo</label>
</div>
- If you decide not to loop over the radio buttons, they'll be output in a
- ``<ul>`` with ``<li>`` tags, as above.
+ That included the ``<label>`` tags. To get more granular, you can use each
+ radio button's ``tag`` and ``choice_label`` attributes. For example, this template...
+
+ .. code-block:: html+django
+
+ {% for radio in myform.beatles %}
+ <label>
+ {{ radio.choice_label }}
+ <span class="radio">{{ radio.tag }}</span>
+ </label>
+ {% endfor %}
+
+ ...will result in the following HTML:
+
+ .. code-block:: html
+
+ <label>
+ John
+ <span class="radio"><input type="radio" name="beatles" value="john" /></span>
+ </label>
+ <label>
+ Paul
+ <span class="radio"><input type="radio" name="beatles" value="paul" /></span>
+ </label>
+ <label>
+ George
+ <span class="radio"><input type="radio" name="beatles" value="george" /></span>
+ </label>
+ <label>
+ Ringo
+ <span class="radio"><input type="radio" name="beatles" value="ringo" /></span>
+ </label>
+
+ If you decide not to loop over the radio buttons -- e.g., if your template simply includes
+ ``{{ myform.beatles }}`` -- they'll be output in a ``<ul>`` with ``<li>`` tags, as above.
``CheckboxSelectMultiple``
~~~~~~~~~~~~~~~~~~~~~~~~~~