You are here

public function GooglePlacesAPI::formProcessInput in Geolocation Field 8

Process from as altered above.

Parameters

array $input: Input values.

string $element_name: Name of the input element.

Return value

array|bool Location data.

Overrides GeocoderBase::formProcessInput

File

modules/geolocation_google_places_api/src/Plugin/geolocation/Geocoder/GooglePlacesAPI.php, line 174

Class

GooglePlacesAPI
Provides the Google Places API.

Namespace

Drupal\geolocation_google_places_api\Plugin\geolocation\Geocoder

Code

public function formProcessInput(array &$input, $element_name) {
  if (!empty($input['geolocation_geocoder_google_places_api']) && empty($input['geolocation_geocoder_google_places_api_state'])) {
    $location_data = $this
      ->geocode($input['geolocation_geocoder_google_places_api']);
    if (empty($location_data)) {
      $input['geolocation_geocoder_google_places_api_state'] = 0;
      return FALSE;
    }
    $input['geolocation_geocoder_google_places_api'] = $location_data['address'];
    $input['geolocation_geocoder_google_places_api_state'] = 1;
    return $location_data;
  }
  return TRUE;
}