mirror of
https://github.com/django/django.git
synced 2025-07-28 15:44:20 +00:00
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
This commit is contained in:
parent
0519adb2a8
commit
fc90c09efd
4 changed files with 87 additions and 1 deletions
|
@ -410,6 +410,16 @@ class BoundField(StrAndUnicode):
|
|||
return self.as_widget() + self.as_hidden(only_initial=True)
|
||||
return self.as_widget()
|
||||
|
||||
def __iter__(self):
|
||||
"""
|
||||
Yields rendered strings that comprise all widgets in this BoundField.
|
||||
|
||||
This really is only useful for RadioSelect widgets, so that you can
|
||||
iterate over individual radio buttons in a template.
|
||||
"""
|
||||
for subwidget in self.field.widget.subwidgets(self.html_name, self.value()):
|
||||
yield self.as_widget(subwidget)
|
||||
|
||||
def _errors(self):
|
||||
"""
|
||||
Returns an ErrorList for this field. Returns an empty ErrorList
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue