You are here

function getlocations_cloudmade_settings_validate in Get Locations 7

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

File

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

Code

function getlocations_cloudmade_settings_validate($form_state) {

  // we need to ensure that any empty cloudmade_maps are not saved
  $mapnum = count($form_state['values']['getlocations_leaflet_cloudmade']['cloudmade_maps']);
  $emptyfound = FALSE;
  for ($ct = 0; $ct < $mapnum; $ct++) {
    if (empty($form_state['values']['getlocations_leaflet_cloudmade']['cloudmade_maps'][$ct]['style_id'])) {
      unset($form_state['values']['getlocations_leaflet_cloudmade']['cloudmade_maps'][$ct]);
      $emptyfound = TRUE;
    }
  }

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