You are here

function organigrams_vocabulary_form_submit in Organigrams 8.2

Same name and namespace in other branches
  1. 8 organigrams.module \organigrams_vocabulary_form_submit()

Custom submit function for the vocabulary add form.

Parameters

array $form: Contains the vocabulary add form.

\Drupal\Core\Form\FormStateInterface $form_state: Contains the form state of the vocabulary add form.

1 string reference to 'organigrams_vocabulary_form_submit'
organigrams_form_alter in ./organigrams.module
Implements hook_form_alter().

File

./organigrams.module, line 101
Extends Taxonomy to create organigrams.

Code

function organigrams_vocabulary_form_submit(array $form, FormStateInterface $form_state) {

  // Get the vocabulary id.
  $vid = $form_state
    ->getValue('vid');

  // Create taxonomy fields.
  organigrams_create_term_fields($vid);

  // Get the vocabulary entity.
  $vocabulary = $form_state
    ->getFormObject()
    ->getEntity();

  // Check if it exists.
  if (!empty($vocabulary)) {

    // Add a setting to indicate this is an organigram.
    $vocabulary
      ->setThirdPartySetting('organigrams', 'is_organigram', TRUE);

    // Save the entity.
    $vocabulary
      ->save();
  }
}