The Autocomplete user allows the user to start typing, then select any of a popped up list of strings, and have the selected string passed to a function at submit time.
However, if the user types their own value, instead of choosing from the list, the string "" is passed to the specified function at submit time. This is right for some apps (where only the choices to be completed from are valid), but wrong for others (where the popped up completions are only suggestions).
here that you load on the page with the form put this
Hope that helps,
Mads Hartmann Jensen
There should be a way to make this happen automatically (especially as this code is JQuery-specific). I'm not sure which behavior should be the default.
[[file:do2WDIrs4r4lmSeJe5cbLA]]: patch to AutoComplete, to add a blur event
I run into the same problem. See discussion [[url:http://groups.google.com/group/liftweb/browse_thread/thread/bbd45a54792f1a1a/e5fefb17816efc3e?lnk=raot|here]]
It is even worse. As it seems, the only time the value of the hidden field is updated - this is the value transmitted back to the server - is when something is selected in the drop down list.
If the user types something into what looks like a text field, this value is not sent to the server, but the value last selected from the list.
This could lead to the following situation: a user selects an article from the list, but then decides to delete the entry. The text field is now empty, but the last selection is sent to the server as value of that input field.
This behavior is, well, unexpected - under any circumstance.
The above patch (against eff1153bc8638218951c8fe3a70a9bad77c4b471 (2.2 final)) adds a blur event that copies the value into the hidden field when the autocomplete widget looses focus (thanks to info from Sergey Andreev).
It is the same functionality as the above snippet, but automatically generated.
Imported from Assembla: http://www.assembla.com/spaces/liftweb/tickets/892
Moved to Widgets module: liftmodules/widgets#4