gform_geolocation_autocomplete_mappings_pre_populate

Description

Allows the mapped autocomplete values to be customized before the values are added to the inputs.

Usage

gform.addFilter( 'gform_geolocation_autocomplete_mappings_pre_populate', function ( mappings, components, place, formId, fieldId ) {

	return mappings;
} );

Parameters

  • mappings object
    A collection of address field elements and values to be populated. Only the values are writable.
    The keys to the object are: line1, line2, city, state, zip, country, latitude, and longitude. Each key is assigned an object that contains the following:
  • components object
    The components for the selected place. Details about how the component objects are defined can be found here. Each component can be accessed using the type as the key, e.g. components.street_number.long_name.
  • place object
    Data about the place selected by the user. Details about what the place object can contain are here.
  • fieldId number
    The ID of the form the address field belongs to.
  • formId number
    The ID of the address field being populated.

Examples

Add a custom value.

gform.addFilter( 'gform_geolocation_autocomplete_mappings_pre_populate', function ( mappings, components, place, formId, fieldId ) {
	mappings.line2.value = 'myVal';

	return mappings;
} );

Placement

Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.

See also the JavaScript/jQuery section in this article: Where Do I Put This Code?

Source Code

This filter is located in getMappings() in google-places.js.

Since

Geolocation 1.3.0