Skip to content

Commit

Permalink
Set something like tmpl_context.form.display(value=school) to test fo…
Browse files Browse the repository at this point in the history
…r unicode values of given "school" or whatever value given. In other words, before, setting a select with an option with the value of a number to an actual number in the given value-dict would not compare correctly, because the option-value would be compared as a unicode string and the given-value would be tested as whatever it was, often a number. This fix applies only to single/multiple select form elements.
  • Loading branch information
audiere@christopher-browns-macbook.local committed Nov 14, 2009
1 parent 0671c3a commit c7f69d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tw2/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def prepare(self):
option_attrs[self.selected_verb] = self.selected_verb

#override if the widget was given an actual value
if ((self.multiple and unicode(option[0]) in value) or
(not self.multiple and unicode(option[0]) == value)):
if ((self.multiple and unicode(option[0]) in [unicode(val) for val in value]) or
(not self.multiple and unicode(option[0]) == unicode(value))):
option_attrs[self.selected_verb] = self.selected_verb

xxx.append((option_attrs, unicode(option[1])))
Expand Down

0 comments on commit c7f69d1

Please sign in to comment.