You are here

function disclaimer_admin_settings_validate in Disclaimer 6

Same name and namespace in other branches
  1. 6.2 disclaimer.admin.inc \disclaimer_admin_settings_validate()
  2. 7 disclaimer.admin.inc \disclaimer_admin_settings_validate()

Validation function for the general configuration form.

Ensure that numeric value are numeric... and set input format

File

./disclaimer.admin.inc, line 373
Admin page callbacks for the disclaimer module.

Code

function disclaimer_admin_settings_validate($form, &$form_state) {
  $age_limit = $form_state['values']['disclaimer_age_limit'];
  if (!empty($age_limit) && (!is_numeric($age_limit) || $age_limit < 0)) {
    form_set_error('disclaimer_age_limit', t('You must enter an age greater than 0.'));
  }
  $modal = explode(',', $form_state['values']['disclaimer_modal_active']);

  // nyromodal
  if (in_array('nyroModal', $modal)) {
    $height = $form_state['values']['disclaimer_height'];
    $width = $form_state['values']['disclaimer_width'];
    $padding = $form_state['values']['disclaimer_padding'];
    $bgcolor = $form_state['values']['disclaimer_bgcolor'];
    if (!empty($height) && (!is_numeric($height) || $height < 0)) {
      form_set_error('disclaimer_height', t('You must enter a height greater than 0 pixels.'));
    }
    if (!empty($width) && (!is_numeric($width) || $width < 0)) {
      form_set_error('disclaimer_width', t('You must enter a width greater than 0 pixels.'));
    }
    if (!empty($padding) && !is_numeric($padding)) {
      form_set_error('disclaimer_padding', t('You must enter a numeric padding.'));
    }
    if (empty($bgcolor)) {
      form_set_error('disclaimer_bgcolor', t('You must enter a bgcolor.'));
    }
  }

  //jqModal
  if (in_array('jqModal', $modal)) {
    $overlay = $form_state['values']['disclaimer_jqmodal_overlay'];
    if (!empty($overlay) && !is_numeric($overlay)) {
      form_set_error('disclaimer_jqmodal_overlay', t('You must enter a numeric overlay.'));
    }
  }
}