function forum_form_node_form_alter

Same name in other branches
  1. 9 core/modules/forum/forum.module \forum_form_node_form_alter()
  2. 8.9.x core/modules/forum/forum.module \forum_form_node_form_alter()
  3. 10 core/modules/forum/forum.module \forum_form_node_form_alter()
  4. 11.x core/modules/forum/forum.module \forum_form_node_form_alter()

Implements hook_form_BASE_FORM_ID_alter() for node_form().

File

modules/forum/forum.module, line 626

Code

function forum_form_node_form_alter(&$form, &$form_state, $form_id) {
    if (isset($form['taxonomy_forums'])) {
        $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 : '';
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.