You are here

function hide_submit_form_alter in Hide submit button 5

Same name and namespace in other branches
  1. 6 hide_submit.module \hide_submit_form_alter()
  2. 7.2 hide_submit.module \hide_submit_form_alter()
  3. 7 hide_submit.module \hide_submit_form_alter()

Implementation of hook_form_alter

Used to add "hide-submit-exclude" class to some forms Avoid conflicts and refine hiding

File

./hide_submit.module, line 112

Code

function hide_submit_form_alter($form_id, &$form) {
  $exclude_forms = explode("\r\n", variable_get('hide_submit_form_exclusion', 'shoutbox_add_form'));
  $found = FALSE;
  $mode = variable_get('hide_submit_form_exclusion_mode', HIDE_SUBMIT_EXCLUDE_LISTED_FORMS);
  foreach ($exclude_forms as $exclude_form_id) {
    if ($form_id == $exclude_form_id) {
      $found = TRUE;
      if ($mode == HIDE_SUBMIT_EXCLUDE_LISTED_FORMS) {
        _hide_submit_add_exclude_class($form);
        if (_hide_submit_debug_on()) {
          drupal_set_message(t("hide_submit: Excluding form %form", array(
            '%form' => $exclude_form_id,
          )));
        }
      }
    }
  }
  if (!$found && $mode == HIDE_SUBMIT_EXCLUDE_UNLISTED_FORMS) {
    _hide_submit_add_exclude_class($form);
    if (_hide_submit_debug_on()) {
      drupal_set_message(t("hide_submit: Excluding form %form", array(
        '%form' => $form_id,
      )));
    }
  }
  _hide_submit_inject();
}