You are here

public static function GeofieldDefaultWidget::validateGeofieldGeometryText in Geofield 8

File

src/Plugin/Field/FieldWidget/GeofieldDefaultWidget.php, line 88

Class

GeofieldDefaultWidget
Widget implementation of the 'geofield_default' widget.

Namespace

Drupal\geofield\Plugin\Field\FieldWidget

Code

public static function validateGeofieldGeometryText(array $element, FormStateInterface &$form_state) {
  if (!empty($element['#value']) && is_null(\Drupal::service('geofield.geophp')
    ->load($element['#value']))) {
    $form_state
      ->setError($element, t('The @value is not a valid geospatial content.', [
      '@value' => $element['#value'],
    ]));
  }
}