How do I get text fields to autocomplete with business names and addresses using google places API?

By: Tony Fontana | Asked: 06/21/2023
ForumsCategory: General questionsHow do I get text fields to autocomplete with business names and addresses using google places API?
Tony Fontana asked 1 year ago
I'm told this is an existing feature request that's not ready yet but that it could be done with some custom code.  Has anyone written code to accomplish this?
1 Answers
Victor Font answered 1 year ago

I've done it for a couple of real estate sites quite awhile ago. You have to enable the Google Places API. How well informed are you about using AJAX API calls? Everything for the DIY'er starts here: https://developers.google.com/maps/documentation/places/web-service

Tony Fontana replied 1 year ago

Thanks, Victor. I've experimented enough now with the google places javascript API where I have a simple form on a page that autocompletes a business name and fills in the full business address. Can my javascript code be applied to two text fields in a Formidable Form? I don't see an obvious way to hook this in.

Tony Fontana replied 1 year ago

I have a working method. I hooked in two additional text fields using the action 'frm_entry_form' that serve as my autocomplete fields. I also have two defined text fields hidden on the form that provides the database storage for the entry. I use the filter 'frm_validate_entry' to copy the autocomplete values into the predefined hidden fields on a submit. I know this is a bit klunky so if there is a more straight-forward way to do this, let me know.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right