id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux
28308,Document removal of Select.render_option(),noxxer,nobody,"Checked and compared the rendering of the form in 1.10 and 1.11. In version 1.11, the method render_option ceased to be called.
{{{
class SelectWithData(forms.widgets.Select):
def __init__(self, *args, **kwargs):
self.options_data = kwargs.pop('options_data', None)
super(SelectWithData, self).__init__(*args, **kwargs)
def render_option(self, selected_choices, option_value, option_label):
if self.options_data and option_value in self.options_data:
price=''
if 'price' in self.options_data[option_value]:
price = self.options_data[option_value]['price']
html = u''.format(
escape(option_value),
price,
conditional_escape(force_unicode(option_label)))
else:
# No options_data
option_value = force_unicode(option_value)
html = u''.format(
escape(option_value),
conditional_escape(force_unicode(option_label)))
return html
class MyForm(forms.Form):
state = forms.ChoiceField(widget=forms.SelectWithData(choices=[]))
}}}",Cleanup/optimization,closed,Documentation,1.11,Normal,fixed,"forms, widgets, Select, render_option",,Accepted,0,0,0,0,0,1