You are here

function leaflet_widget_widget_validate in Leaflet Widget for Geofield 7

Same name and namespace in other branches
  1. 7.2 leaflet_widget.module \leaflet_widget_widget_validate()
1 string reference to 'leaflet_widget_widget_validate'
leaflet_widget_field_widget_form in ./leaflet_widget.module
Implements hook_field_widget_form().

File

./leaflet_widget.module, line 152

Code

function leaflet_widget_widget_validate($element, &$form_state) {
  $geophp = geophp_load();
  if (!$geophp) {
    return FALSE;
  }
  $geojson = json_decode($element['wkt']['#value']);
  $results = array();
  if ($geojson->type === 'FeatureCollection') {
    foreach ($geojson->features as $feature) {
      $results[] = array_merge($results, leaflet_widget_process_geojson($feature));
    }
  }
  else {
    $results = array(
      leaflet_widget_process_geojson($geojson),
    );
  }
  form_set_value($element, $results, $form_state);
}