#28308 closed Cleanup/optimization (fixed)
Document removal of Select.render_option()
Reported by: | noxxer | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.11 |
Severity: | Normal | Keywords: | forms, widgets, Select, render_option |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
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'<option value="{}" price="{}" >{}</option>'.format( escape(option_value), price, conditional_escape(force_unicode(option_label))) else: # No options_data option_value = force_unicode(option_value) html = u'<option value="{}">{}</option>'.format( escape(option_value), conditional_escape(force_unicode(option_label))) return html class MyForm(forms.Form): state = forms.ChoiceField(widget=forms.SelectWithData(choices=[]))
Change History (3)
comment:1 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 8 years ago
Component: | Forms → Documentation |
---|---|
Summary: | In 1.11 does not call the function render_option in custom widget (forms.widgets.Select) → Document removal of Select.render_option() |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Usually we don't document removal of undocumented APIs but I suppose it doesn't hurt here.
Note:
See TracTickets
for help on using tickets.
In f2b69863: