You are here

public function GooglePlacesAPI::formValidateInput in Geolocation Field 8

Process from as altered above.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: Input values.

Return value

bool True of false.

Overrides GeocoderBase::formValidateInput

File

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

Class

GooglePlacesAPI
Provides the Google Places API.

Namespace

Drupal\geolocation_google_places_api\Plugin\geolocation\Geocoder

Code

public function formValidateInput(FormStateInterface $form_state) {
  $input = $form_state
    ->getUserInput();
  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)) {
      $form_state
        ->setErrorByName('geolocation_geocoder_google_places_api', $this
        ->t('Failed to geocode %input.', [
        '%input' => $input['geolocation_geocoder_google_places_api'],
      ]));
      return FALSE;
    }
  }
  return TRUE;
}