summaryrefslogtreecommitdiff
path: root/django/forms/widgets.py
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2013-04-12 23:22:31 +0200
committerClaude Paroz <claude@2xlibre.net>2013-04-13 12:23:25 +0200
commitc4186c2fec6f5418c81366a911792bf5295db494 (patch)
treef468670cab6f843e532b6be423ea1ac19be359b6 /django/forms/widgets.py
parentf56b703b2748c958468344d894902ac18ec36d78 (diff)
Fixed #4117: Apply id attribute to the outer <ul> of RadioSelect
Diffstat (limited to 'django/forms/widgets.py')
-rw-r--r--django/forms/widgets.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 41263b0905..b0e355eeb6 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -646,10 +646,13 @@ class RadioFieldRenderer(object):
def render(self):
"""Outputs a <ul> for this set of radio fields."""
- return format_html('<ul>\n{0}\n</ul>',
- format_html_join('\n', '<li>{0}</li>',
- [(force_text(w),) for w in self]
- ))
+ id_ = self.attrs.get('id', None)
+ start_tag = format_html('<ul id="{0}">', id_) if id_ else '<ul>'
+ output = [start_tag]
+ for widget in self:
+ output.append(format_html('<li>{0}</li>', force_text(widget)))
+ output.append('</ul>')
+ return mark_safe('\n'.join(output))
class RadioSelect(Select):
renderer = RadioFieldRenderer