1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Fixed #4117: Apply id attribute to the outer <ul> of RadioSelect

This commit is contained in:
Baptiste Mispelon
2013-04-12 23:22:31 +02:00
committed by Claude Paroz
parent f56b703b27
commit c4186c2fec
5 changed files with 20 additions and 12 deletions

View File

@@ -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