forum_form_alter

Versions
mediamosa-21
forum_form_alter(&$form, $form_state, $form_id)

Implements hook_form_alter().

Code

modules/forum/forum.module, line 548

<?php
function forum_form_alter(&$form, $form_state, $form_id) {
  $vid = variable_get('forum_nav_vocabulary', 0);
  if (isset($form['vid']) && $form['vid']['#value'] == $vid) {
    // Hide critical options from forum vocabulary.
    if ($form_id == 'taxonomy_form_vocabulary') {
      $form['help_forum_vocab'] = array(
        '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
        '#weight' => -1,
      );
      $form['hierarchy'] = array('#type' => 'value', '#value' => 1);
      $form['delete']['#access'] = FALSE;
    }
    // Hide multiple parents select from forum terms.
    elseif ($form_id == 'taxonomy_form_term') {
      $form['advanced']['parent']['#access'] = FALSE;
    }
  }
  if ($form_id == 'forum_node_form') {
    $langcode = $form['taxonomy_forums']['#language'];
    // Make the vocabulary required for 'real' forum-nodes.
    $form['taxonomy_forums'][$langcode]['#required'] = TRUE;
    $form['taxonomy_forums'][$langcode]['#multiple'] = FALSE;
    if (empty($form['taxonomy_forums'][$langcode]['#default_value'])) {
      // If there is no default forum already selected, try to get the forum
      // ID from the URL (e.g., if we are on a page like node/add/forum/2, we
      // expect "2" to be the ID of the forum that was requested).
      $requested_forum_id = arg(3);
      $form['taxonomy_forums'][$langcode]['#default_value'] = is_numeric($requested_forum_id) ? $requested_forum_id : NULL;
    }
  }
}
?>