Filter/hook to use state abbreviation for Geolocation addon?

We are using the “Gravity Forms Geolocation Add-On” and wondering if there is a way to have Google populate the abbreviation, rather than the full name, in the state field.

Are you using a country specific type of address field, or the international version?

1 Like

International version

In that case, you can use the gform_geolocation_autocomplete_mappings_pre_populate filter to customize the mappings.

Try the following:

gform.addFilter( 'gform_geolocation_autocomplete_mappings_pre_populate', function ( mappings, components, place, formId, fieldId ) {
    mappings.state.value = components.administrative_area_level_1.short_name;
 
    return mappings;
} );
2 Likes

That worked great, thank you for the quick response!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.