From fc90c09efdfbc029d43e6d4c0952ed6b49f6f34d Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 7 Dec 2011 22:31:39 +0000 Subject: Made BoundFields iterable, so that you can iterate over individual radio buttons of a RadioSelect in a template git-svn-id: http://code.djangoproject.com/svn/django/trunk@17173 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/forms/widgets.txt | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'docs/ref/forms') diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 2b386c0864..b657be4c53 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -345,7 +345,8 @@ commonly used groups of widgets: .. class:: RadioSelect - Similar to :class:`Select`, but rendered as a list of radio buttons: + Similar to :class:`Select`, but rendered as a list of radio buttons within + ``
  • `` tags: .. code-block:: html @@ -354,6 +355,40 @@ commonly used groups of widgets: ... + .. versionadded:: 1.4 + + For more granular control over the generated markup, you can loop over the + radio buttons in the template. Assuming a form ``myform`` with a field + ``beatles`` that uses a ``RadioSelect`` as its widget: + + .. code-block:: html+django + + {% for radio in myform.beatles %} +
    + {{ radio }} +
    + {% endfor %} + + This would generate the following HTML: + + .. code-block:: html + +
    + +
    +
    + +
    +
    + +
    +
    + +
    + + If you decide not to loop over the radio buttons, they'll be output in a + ``