=== modified file 'django/newforms/widgets.py'
|
|
|
253 | 253 | |
254 | 254 | def __unicode__(self): |
255 | 255 | "Outputs a <ul> for this set of radio fields." |
256 | | return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % w for w in self]) |
| 256 | contents = u'\n'.join([u'<li>%s</li>' % w for w in self]) |
| 257 | return u'<ul%s>\n%s\n</ul>' % (flatatt(self.attrs), contents) |
257 | 258 | |
258 | 259 | class RadioSelect(Select): |
259 | 260 | def render(self, name, value, attrs=None, choices=()): |
… |
… |
|
278 | 279 | if value is None: value = [] |
279 | 280 | has_id = attrs and 'id' in attrs |
280 | 281 | final_attrs = self.build_attrs(attrs, name=name) |
281 | | output = [u'<ul>'] |
| 282 | output = [u'<ul%s>' % flatatt(final_attrs)] |
282 | 283 | str_values = set([smart_unicode(v) for v in value]) # Normalize to strings. |
283 | 284 | for i, (option_value, option_label) in enumerate(chain(self.choices, choices)): |
284 | 285 | # If an ID attribute was given, add a numeric index as a suffix, |
… |
… |
|
287 | 288 | final_attrs = dict(final_attrs, id='%s_%s' % (attrs['id'], i)) |
288 | 289 | cb = CheckboxInput(final_attrs, check_test=lambda value: value in str_values) |
289 | 290 | option_value = smart_unicode(option_value) |
| 291 | option_label = escape(smart_unicode(option_label)) |
290 | 292 | rendered_cb = cb.render(name, option_value) |
291 | | output.append(u'<li><label>%s %s</label></li>' % (rendered_cb, escape(smart_unicode(option_label)))) |
| 293 | contents = u'<label>%s %s</label>' % (rendered_cb, option_label) |
| 294 | output.append(u'<li%s>%s</li>' % (flatatt(final_attrs), contents)) |
292 | 295 | output.append(u'</ul>') |
293 | 296 | return u'\n'.join(output) |
294 | 297 | |