You are here

public function Dummy::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

tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php, line 94

Class

Dummy
Provides the Google Geocoding API.

Namespace

Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder

Code

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