Same name and namespace in other branches
  1. 4.7.x modules/forum.module \forum_form_alter()
  2. 5.x modules/forum/forum.module \forum_form_alter()

Implementation of hook_form_alter().

File

modules/forum/forum.module, line 360
Enable threaded discussions about general topics.

Code

function forum_form_alter(&$form, $form_state, $form_id) {
  $vid = variable_get('forum_nav_vocabulary', '');
  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(
        '#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
        '#weight' => -1,
      );
      $form['content_types']['nodes']['#required'] = TRUE;
      $form['hierarchy'] = array(
        '#type' => 'value',
        '#value' => 1,
      );
      $form['settings']['required'] = array(
        '#type' => 'value',
        '#value' => FALSE,
      );
      $form['settings']['relations'] = array(
        '#type' => 'value',
        '#value' => FALSE,
      );
      $form['settings']['tags'] = array(
        '#type' => 'value',
        '#value' => FALSE,
      );
      $form['settings']['multiple'] = array(
        '#type' => 'value',
        '#value' => FALSE,
      );
      unset($form['delete']);
    }
    elseif ($form_id == 'taxonomy_form_term') {
      $form['advanced']['parent']['#access'] = FALSE;
    }
  }
  if ($form_id == 'forum_node_form') {

    // Make the vocabulary required for 'real' forum-nodes.
    $vid = variable_get('forum_nav_vocabulary', '');
    $form['taxonomy'][$vid]['#required'] = TRUE;
    $form['taxonomy'][$vid]['#options'][''] = t('- Please choose -');
  }
}