public function VocabularyFormController::save

Overrides Drupal\Core\Entity\EntityFormController::save().

Overrides EntityFormController::save

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php, line 170
Definition of Drupal\taxonomy\VocabularyFormController.

Class

VocabularyFormController
Base form controller for vocabulary edit forms.

Namespace

Drupal\taxonomy

Code

public function save(array $form, array &$form_state) {
  $vocabulary = $this
    ->getEntity($form_state);

  // Prevent leading and trailing spaces in vocabulary names.
  $vocabulary->name = trim($vocabulary->name);
  switch (taxonomy_vocabulary_save($vocabulary)) {
    case SAVED_NEW:
      drupal_set_message(t('Created new vocabulary %name.', array(
        '%name' => $vocabulary->name,
      )));
      watchdog('taxonomy', 'Created new vocabulary %name.', array(
        '%name' => $vocabulary->name,
      ), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
      $form_state['redirect'] = 'admin/structure/taxonomy/' . $vocabulary->machine_name;
      break;
    case SAVED_UPDATED:
      drupal_set_message(t('Updated vocabulary %name.', array(
        '%name' => $vocabulary->name,
      )));
      watchdog('taxonomy', 'Updated vocabulary %name.', array(
        '%name' => $vocabulary->name,
      ), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit'));
      $form_state['redirect'] = 'admin/structure/taxonomy';
      break;
  }
  $form_state['values']['vid'] = $vocabulary->vid;
  $form_state['vid'] = $vocabulary->vid;
}