You are here

function fac_settings_form_validate in Fast Autocomplete 7

Fast Autocomplete settings form validation callback.

File

inc/fac.admin.inc, line 219
This file contains the settings forms of the Fast Autocomplete module.

Code

function fac_settings_form_validate(&$form, &$form_state) {
  if ($form_state['clicked_button']['#name'] == 'delete') {
    drupal_goto('admin/config/search/fac/delete');
  }
  if ($form_state['values']['fac_all_results_link']) {
    if (!is_numeric($form_state['values']['fac_all_results_link_threshold'])) {
      form_set_error('fac_all_results_link_threshold', t('Please enter zero or a positive number.'));
    }
    else {
      if ($form_state['values']['fac_all_results_link_threshold'] < 0) {
        form_set_error('fac_all_results_link_threshold', t('The minimum value is 0.'));
      }
    }
  }
  if (!is_numeric($form_state['values']['fac_key_min_length'])) {
    form_set_error('fac_key_min_length', t('Please enter a positive number.'));
  }
  else {
    if ($form_state['values']['fac_key_min_length'] < 1) {
      form_set_error('fac_key_min_length', t('The minimum value is 1.'));
    }
  }
  if (!is_numeric($form_state['values']['fac_key_max_length'])) {
    form_set_error('fac_key_max_length', t('Please enter a positive number.'));
  }
  else {
    if ($form_state['values']['fac_key_max_length'] < 1) {
      form_set_error('fac_key_max_length', t('The minimum value is 1'));
    }
  }
  if (!is_numeric($form_state['values']['fac_breakpoint'])) {
    form_set_error('fac_breakpoint', t('Please enter zero or a positive number.'));
  }
  else {
    if ($form_state['values']['fac_breakpoint'] < 0) {
      form_set_error('fac_breakpoint', t('The minimum value is 0.'));
    }
  }
  if ($form_state['values']['fac_clean_up_files'] == 1 && empty($form_state['values']['fac_files_expire_time'])) {
    form_set_error('fac_files_expire_time', t('The field expire time is required!'));
  }
  if ($form_state['values']['fac_bulk_generate_json_enabled'] == 1 && empty($form_state['values']['fac_bulk_generate_json_size'])) {
    form_set_error('fac_bulk_generate_json_size', t('The field size is required!'));
  }
  if (strpos($form_state['values']['fac_result_location'], ',') !== FALSE) {
    form_set_error('fac_result_location', t('Please enter one selector'));
  }
}