Ticket #1314 (reopened defect)

Opened 1 year ago

Last modified 4 days ago

SelectionField does not format values being rendered in template

Reported by: rick446 Assigned to: anonymous
Priority: low Milestone: 1.1
Component: Widgets Version: 1.0.4b3
Severity: normal Keywords:
Cc:

Description

As documented in this thread, the SelectionField "values" parameter expects a list of the form [(value, display, attrs)] where value is a "Python" value, in the FormEncode sense. The template, then, should render that value to the <option> list using the SelectionField validator's from_python method. Furthermore, when a SelectionField is checking to see if a particular option is selected, it should not do any validator conversion, since it is comparing two "Python" values.

I have attached a patch (with a test) which converts outgoing SelectionField values and sets the "selected" attribute on the options correctly.

Attachments

selection_field_patch.diff (3.5 kB) - added by rick446 on 03/05/07 08:49:27.
Patch to turbogears/widgets/forms.py and turbogears/widgets/tests/test_widgets.py

Change History

03/05/07 08:49:27 changed by rick446

  • attachment selection_field_patch.diff added.

Patch to turbogears/widgets/forms.py and turbogears/widgets/tests/test_widgets.py

04/06/07 07:34:24 changed by alberto

  • status changed from new to closed.
  • resolution set to fixed.

I've applied your patch but modified it in order not no remove the to_python conversion in _is_option_selected because it is needed when form redisplays itself because of errors as the value is a string in thta case while options are still python values.

Thanks :)

Alberto

04/06/07 07:35:12 changed by alberto

BTW, applied at [2843]

04/12/07 10:39:48 changed by alberto

  • status changed from closed to reopened.
  • resolution deleted.

I had to revert this patch in [2862]. See this thread for more info.

Alberto

04/12/07 10:39:55 changed by alberto

  • summary changed from [PATCH] SelectionField does not format values being rendered in template to SelectionField does not format values being rendered in template.

05/01/07 12:57:00 changed by alberto

  • milestone changed from 1.0.2 to 1.0.3.

07/03/07 11:33:13 changed by faide

  • milestone changed from 1.0.3 to 1.1.

12/19/07 04:47:05 changed by Chris Arndt

  • version changed from trunk to 1.0.4b3.

08/22/08 10:00:17 changed by Chris Arndt

  • priority changed from normal to low.

Setting this to low priority, because TG is moving to toscawidgets in the future.

08/24/08 10:27:00 changed by faide

  • milestone changed from 1.5 to 1.1.