You are here

public static function GeocoderAutocomplete::validateFormElement in Geocoder autocomplete 8

Form element validate handler.

Parameters

array $element: The form element to validate.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

File

src/Plugin/Field/FieldWidget/GeocoderAutocomplete.php, line 64

Class

GeocoderAutocomplete
Implements geocoder_autocomplete widget on 'string' fields.

Namespace

Drupal\geocoder_autocomplete\Plugin\Field\FieldWidget

Code

public static function validateFormElement(array $element, FormStateInterface $form_state) {
  if ($geocoded_address = $element['#value']) {
    $geocoded_address_cleaned = trim($geocoded_address, '"');
    $form_state
      ->setValueForElement($element, $geocoded_address_cleaned);
  }
}