function forum_form_taxonomy_vocabulary_form_alter

forum_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $form_state, $form_id)

Implements hook_form_BASE_FORM_ID_alter() for \Drupal\taxonomy\VocabularyForm.

File

core/modules/forum/forum.module, line 287
Provides discussion forums.

Code

function forum_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $vid = \Drupal::config('forum.settings')->get('vocabulary');
  $vocabulary = $form_state->getFormObject()->getEntity();
  if ($vid == $vocabulary->id()) {
    $form['help_forum_vocab'] = array(
      '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
      '#weight' => -1,
    );
    // Forum's vocabulary always has single hierarchy. Forums and containers
    // have only one parent or no parent for root items. By default this value
    // is 0.
    $form['hierarchy']['#value'] = TAXONOMY_HIERARCHY_SINGLE;
    // Do not allow to delete forum's vocabulary.
    $form['actions']['delete']['#access'] = FALSE;
    // Do not allow to change a vid of forum's vocabulary.
    $form['vid']['#disabled'] = TRUE;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!forum!forum.module/function/forum_form_taxonomy_vocabulary_form_alter/8.1.x