diff -u -r django.orig/forms/widgets.py django/forms/widgets.py
old
|
new
|
|
414 | 414 | return u'<option value="%s"%s>%s</option>' % ( |
415 | 415 | escape(option_value), selected_html, |
416 | 416 | conditional_escape(force_unicode(option_label))) |
| 417 | def render_group(option_value, option_label): |
| 418 | return u'<optgroup label="%s">%s</optgroup>' %(escape(force_unicode(option_value)),''.join(process_list(option_label))) |
| 419 | def process_list(l): |
| 420 | output = [] |
| 421 | for option_value, option_label in l: |
| 422 | if isinstance(option_label, (list, tuple)): |
| 423 | output.append(render_group(option_value, option_label)) |
| 424 | else: |
| 425 | output.append(render_option(option_value, option_label)) |
| 426 | return output |
417 | 427 | # Normalize to strings. |
418 | 428 | selected_choices = set([force_unicode(v) for v in selected_choices]) |
419 | | output = [] |
420 | | for option_value, option_label in chain(self.choices, choices): |
421 | | if isinstance(option_label, (list, tuple)): |
422 | | output.append(u'<optgroup label="%s">' % escape(force_unicode(option_value))) |
423 | | for option in option_label: |
424 | | output.append(render_option(*option)) |
425 | | output.append(u'</optgroup>') |
426 | | else: |
427 | | output.append(render_option(option_value, option_label)) |
| 429 | output = process_list(chain(self.choices, choices)) |
428 | 430 | return u'\n'.join(output) |
429 | 431 | |
430 | 432 | class NullBooleanSelect(Select): |