You are here

function getlocations_mapbox_settings_validate in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_mapbox/getlocations_mapbox.module \getlocations_mapbox_settings_validate()
1 call to getlocations_mapbox_settings_validate()
getlocations_leaflet_settings_validate in modules/getlocations_leaflet/getlocations_leaflet.module
Function

File

modules/getlocations_mapbox/getlocations_mapbox.module, line 85
getlocations_mapbox.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_mapbox_settings_validate($form_state) {

  // dump empty mapbox
  $mapnum = count($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info']);
  $emptyfound = FALSE;
  for ($ct = 0; $ct < $mapnum; $ct++) {
    if (empty($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'][$ct]['key']) || empty($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'][$ct]['label']) || empty($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'][$ct]['token'])) {
      unset($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'][$ct]);
      $emptyfound = TRUE;
    }
  }

  // reorder them in case some clown empties one before the last one
  if ($emptyfound) {
    $mapnum = count($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info']);
    $temp = array();
    $ct = 0;
    foreach ($form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'] as $k => $v) {
      $temp[$ct] = $v;
      $ct++;
    }
    if (count($temp)) {
      $form_state['values']['getlocations_leaflet_mapbox']['mapbox_info'] = $temp;
    }
  }
  return $form_state;
}