Skip to content

Instantly share code, notes, and snippets.

@claygriffiths
Created March 8, 2022 01:43
Show Gist options
  • Save claygriffiths/c5573f078858c6271a393fb8ad787ca8 to your computer and use it in GitHub Desktop.
Save claygriffiths/c5573f078858c6271a393fb8ad787ca8 to your computer and use it in GitHub Desktop.
GP Address Autocomplete: Show Cities as Results
/**
* Gravity Perks // GP Address Autocomplete // Show Cities as Results
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete
*
* Instructions:
* 1. Install our free Custom JavaScript for Gravity Forms plugin.
* Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
* 3. Install accompanying gpaa-autocomplete-cities.php snippet
*/
window.gform.addFilter( 'gpaa_autocomplete_options', function( options ) {
options.types = ['(cities)'];
return options;
} );
<?php
/**
* Gravity Perks // GP Address Autocomplete // Show Cities as Results
* https://gravitywiz.com/documentation/gravity-forms-address-autocomplete
*
* Instructions:
* 1. Install snippet per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
* 2. Update FORMID and FIELDID accordingly
* 3. Hide the Address Line 1 and Address Line 2 inputs from the Form Editor if desired.
* 4. Install accompanying gpaa-autocomplete-cities.js snippet
*/
add_filter( 'gpaa_init_args_FORMID_FIELDID', function( $args ) {
$args['inputSelectors']['autocomplete'] = '#input_FORMID_FIELDID_3';
return $args;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment