You are here

function getlocations_fields_settings_validate in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/getlocations_fields.admin.inc \getlocations_fields_settings_validate()

Validation function

1 string reference to 'getlocations_fields_settings_validate'
getlocations_fields_settings_form in modules/getlocations_fields/getlocations_fields.admin.inc
Function to display the getlocations admin settings form

File

modules/getlocations_fields/getlocations_fields.admin.inc, line 123
getlocations_fields.admin.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_settings_validate($form, &$form_state) {
  if (empty($form_state['values']['getlocations_fields_defaults']['input_address_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_address_width']) || $form_state['values']['getlocations_fields_defaults']['input_address_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_address_width', t('Search textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_name_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_name_width']) || $form_state['values']['getlocations_fields_defaults']['input_name_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_name_width', t('Name textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_street_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_street_width']) || $form_state['values']['getlocations_fields_defaults']['input_street_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_street_width', t('Street textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_additional_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_additional_width']) || $form_state['values']['getlocations_fields_defaults']['input_additional_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_additional_width', t('Additional textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_city_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_city_width']) || $form_state['values']['getlocations_fields_defaults']['input_city_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_city_width', t('City textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_province_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_province_width']) || $form_state['values']['getlocations_fields_defaults']['input_province_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_province_width', t('Province textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_postal_code_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_postal_code_width']) || $form_state['values']['getlocations_fields_defaults']['input_postal_code_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_postal_code_width', t('Postal code textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_country_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_country_width']) || $form_state['values']['getlocations_fields_defaults']['input_country_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_country_width', t('Country textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_latitude_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_latitude_width']) || $form_state['values']['getlocations_fields_defaults']['input_latitude_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_latitude_width', t('Latitude textbox must be a positive number'));
  }
  if (empty($form_state['values']['getlocations_fields_defaults']['input_longitude_width']) || !is_numeric($form_state['values']['getlocations_fields_defaults']['input_longitude_width']) || $form_state['values']['getlocations_fields_defaults']['input_longitude_width'] < 1) {
    form_set_error('getlocations_fields_defaults][input_longitude_width', t('Longitude textbox must be a positive number'));
  }

  // css check
  if (isset($form_state['values']['getlocations_fields_defaults']['width'])) {
    if ($check = getlocations_dim_check($form_state['values']['getlocations_fields_defaults']['width'])) {
      $form_state['values']['getlocations_fields_defaults']['width'] = $check;
    }
    else {
      form_set_error('getlocations_fields_defaults][width', t('Width must be valid css'));
    }
  }
  if (isset($form_state['values']['getlocations_fields_defaults']['height'])) {
    if ($check = getlocations_dim_check($form_state['values']['getlocations_fields_defaults']['height'])) {
      $form_state['values']['getlocations_fields_defaults']['height'] = $check;
    }
    else {
      form_set_error('getlocations_fields_defaults][height', t('Height must be valid css'));
    }
  }
  if (isset($form_state['values']['getlocations_fields_defaults']['display_mapwidth'])) {
    if ($check = getlocations_dim_check($form_state['values']['getlocations_fields_defaults']['display_mapwidth'])) {
      $form_state['values']['getlocations_fields_defaults']['display_mapwidth'] = $check;
    }
    else {
      form_set_error('getlocations_fields_defaults][display_mapwidth', t('Width must be valid css'));
    }
  }
  if (isset($form_state['values']['getlocations_fields_defaults']['display_mapheight'])) {
    if ($check = getlocations_dim_check($form_state['values']['getlocations_fields_defaults']['display_mapheight'])) {
      $form_state['values']['getlocations_fields_defaults']['display_mapheight'] = $check;
    }
    else {
      form_set_error('getlocations_fields_defaults][display_mapheight', t('Height must be valid css'));
    }
  }
  $reset = $form_state['values']['getlocations_fields_paths']['reset'];
  unset($form_state['values']['getlocations_fields_paths']['reset']);
  if ($reset == 1) {
    $form_state['values']['getlocations_fields_paths'] = getlocations_fields_paths_get(TRUE);
  }
  elseif ($reset == 2) {
    $form_state['values']['getlocations_fields_paths'] = getlocations_fields_paths_get(FALSE, TRUE);
  }
}