public function VocabularyFormController::save

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

Overrides EntityFormController::save

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php, line 147
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->entity;

  // Prevent leading and trailing spaces in vocabulary names.
  $vocabulary->name = trim($vocabulary->name);
  switch ($vocabulary
    ->save()) {
    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/manage/' . $vocabulary
        ->id() . '/edit'));
      $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $vocabulary
        ->id();
      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/manage/' . $vocabulary
        ->id() . '/edit'));
      $form_state['redirect'] = 'admin/structure/taxonomy';
      break;
  }
  $form_state['values']['vid'] = $vocabulary
    ->id();
  $form_state['vid'] = $vocabulary
    ->id();
}