You are here

function disclaimer_admin_settings_validate in Disclaimer 7

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

Validation function for the general configuration form.

File

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

Code

function disclaimer_admin_settings_validate($form, &$form_state) {

  // Validate content and footer.
  if ($form_state['values']['disclaimer_main_source'] == 1) {
    if (trim($form_state['values']['disclaimer_main_node']) == '') {
      form_set_error('disclaimer_main_node', t('Please select a node.'));
    }
    else {
      $form_state['values']['disclaimer_main_node'] = _disclaimer_validate_title($form, $form_state, 'disclaimer_main_node');
    }
  }
  if ($form_state['values']['disclaimer_footer_source'] == 1) {
    if (trim($form_state['values']['disclaimer_footer_node']) == '') {
      form_set_error('disclaimer_footer_node', t('Please select a node.'));
    }
    else {
      $form_state['values']['disclaimer_footer_node'] = _disclaimer_validate_title($form, $form_state, 'disclaimer_footer_node');
    }
  }

  // Validate image selection.
  if ($form_state['values']['disclaimer_action_type'] == 'image') {
    if (!isset($form_state['values']['disclaimer_enter_img']) || $form_state['values']['disclaimer_enter_img'] == 0) {
      form_set_error('disclaimer_enter_img', t('Please select an image to upload.'));
    }
    if (!isset($form_state['values']['disclaimer_exit_img']) || $form_state['values']['disclaimer_exit_img'] == 0) {
      form_set_error('disclaimer_exit_img', t('Please select an image to upload.'));
    }
  }
}