You are here

public static function GeocodeFormatterBase::validateProvidersSettingsForm in Geocoder 8.3

Validates the providers selection.

Parameters

array $element: The form API form element.

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

File

modules/geocoder_field/src/Plugin/Field/GeocodeFormatterBase.php, line 310

Class

GeocodeFormatterBase
Base Plugin implementation of the Geocode formatter.

Namespace

Drupal\geocoder_field\Plugin\Field

Code

public static function validateProvidersSettingsForm(array $element, FormStateInterface &$form_state) {
  $providers = !empty($element['#value']) ? array_filter($element['#value'], function ($value) {
    return isset($value['checked']) && TRUE == $value['checked'];
  }) : [];
  if (empty($providers)) {
    $form_state
      ->setError($element, t('The selected Geocode operation needs at least one provider.'));
  }
}