Description
The gform_geolocation_place_autocomplete_element_place_details
filter allows developers to edit the requested fields from the Google Places API. This filter replaces the deprecated gform_geolocation_autocomplete_options_pre_init
filter since Geolocation 1.5.0.
Usage
gform.addFilter('gform_geolocation_place_autocomplete_element_place_details', function(placeDetails, formId, fieldId, address) {
// Your Custom Logic
return placeDetails;
});
Parameters
Parameter | Type | Description |
---|---|---|
placeDetails | object | The Field options. |
formId | number | The ID of the form the address field belongs to. |
fieldId | number | The ID of the address field autocomplete is to be initialized for. |
address | element | The Address field element. |
More information about the API: https://developers.google.com/maps/documentation/javascript/reference/place#Place.fetchField
Examples
Include the displayName as an additional return value from the place.fetchFields() call.
gform.addFilter('gform_geolocation_place_autocomplete_element_place_details', function(placeDetails, formId, fieldId, address) {
// Add 'displayName' if it's not already included
if (!placeDetails.fields.includes('displayName')) {
placeDetails.fields.push('displayName');
}
return placeDetails;
});
Placement
Reference the article Adding JavaScript Code to the Frontend of Your Site.
Source Code
The filter is located in assets/js/src/theme/geolocation/google-place-address-element.js
Since
Geolocation 1.5.0