autocomplete behaviour

autocomplete behaviour

I am struggling a little bit with the intended behaviour of the
autocomplete widget. Currently possible items have a value
which the
plugin calls the 'result' currently
and a label. The label is shown in
the suggestions menu. Once you select an item its value is shown in the
input field. This approach is problematic for systems where you want to
use an internal value such as a database id. Currently in those
situations you will end up with a UI like this:

----------------------
Select your city:
Leiden

Leiderdorp

...

----------------------
<user selects a city>

----------------------
Select your city:
16

----------------------
as you can see this is not very user friendly. For these situations you
want to have a value which is returned to the server, a label which is
shown in the input field for a selected item, and optionally a longer
info text which is shown in the suggestions menu. The Selectmenu widget
supports that model, but does not scale well when you have many possible
options.
In my application I always want to return an internal id instead of a
human-readable label to the backend, so the current autocomplete
approach does not work for me. I am considering to refactor it to
support value/label/info data for items. Most likely that will mean that
we need a new hidden input element to store the selected value, and
rename the original input or select element.
Before I embark on that mission I'ld like to hear some feedback from
other. Does thus sound like a sensible approach?
Wichert,
--