You are here

function simplify_form_taxonomy_vocabulary_form_alter in Simplify 8

Implements hook_form_FORM_ID_alter() for taxonomy_form_vocabulary().

File

./simplify.module, line 112
Hooks implemented by the simplify module.

Code

function simplify_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $form_state) {
  $vocabulary = $form['vid'];

  // Taxonomy.
  $form['simplify'] = [
    '#type' => 'details',
    '#title' => t('Simplify'),
    '#description' => t('These fields will be hidden from <em>@vocabulary</em> taxonomy term forms. Disabled checkboxes indicate fields that have been hidden globally on the <a href="@global">Simplify administration page</a>.', [
      '@vocabulary' => $form['name']['#default_value'],
      '@global' => Url::fromRoute('simplify.admin')
        ->toString(),
    ]),
    '#access' => \Drupal::currentUser()
      ->hasPermission('administer simplify'),
    '#group' => 'additional_settings',
  ];
  $form['simplify']['simplify_taxonomies'] = [
    '#type' => 'checkboxes',
    '#title' => t('Simplify the following options'),
    '#options' => simplify_get_fields('taxonomy'),
    '#default_value' => _simplify_get_config_value('simplify_taxonomies', [], 'simplify.vocabulary.' . $vocabulary['#default_value']),
    '#after_build' => [
      '_simplify_disable_globally_hidden_checkboxes',
    ],
  ];

  // Add custom submit function.
  $form['actions']['submit']['#submit'][] = 'simplify_taxonomy_vocabulary_form_submit';
}