klipstein/dojango — Issue #64: 64 - ComboBox returned value does not correspond to key in the given choices 
Author: klipstein
Created: 2011-11-06 13:03:10+00:00
State: open

What steps will reproduce the problem?
1. Create a combobox widget for a field with choices = (('k1', 'Text 1'), ('k2', 'Text 2'))
2. Select one of the options in the resulting page
3. The field will not validate the result

Please provide any additional information below.
The problem is that dijit.form.ComboBox returns the text rather than the value of the selection. To alleviate this ComboBox should override the basic value_from_datadict-method, like this:

def value_from_datadict(self, data, files, name):
value = data.get(name, None)
reverse_lookup = dict([ (text, key) for (key, text) in self.choices ])
return reverse_lookup.get(value, value)

I have tested this, and it seems to work.

Original link: http://code.google.com/p/dojango/issues/detail?id=64