New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete() should have option to allow user to enter their own value #4

d6y opened this Issue Apr 23, 2013 · 2 comments


None yet
1 participant

d6y commented Apr 23, 2013

See: lift/framework#892 (imported from

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).

The following javascript, from Mads Jensen, can be manually added to the page to fix this behavior:

Am I correct in assuming that what you want is to be able to submit a value that isn't part of the drop-down box? If this is the case you can fix it with a bit of javascript. In a javascript somew\
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.


This comment has been minimized.


d6y commented Apr 23, 2013

From @MrMistr

I run into the same problem. See discussion:|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.


This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment