If you are familiar with the location module you would know that when creating a location the state/province textfield predicts options as you type. These options come from a file in the Location module.

I need to re-create that for the city field. Can you please point me in the right direction of how to accomplish this? I want to avoid user typos.

Do I need to create a module of my own or do I hack Location.module ???


1 Answer 1


What this is is an autocomplete field. My guess is if you want to recreate it for another field within the same module then you will indeed need to hack Location module. You'll want to look at the autocomplete callback for the state/province field as well as the autocomplete properties set on the field itself.

However, this may be difficult to do with cities, which is probably why it hasn't been done in Location. If you want to an autocomplete field for cities that actually adheres to the cities wiin a state/province, or even if it doesn't adhere, it will require a full list of cities within each state/province. That's a pretty hefty task if you ask me, but it certainly isn't impossible. I would check around the Location issue queue to see if this has been discussed before. Maybe you can gain information on why it was never done and what the drawbacks may be to developing this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.