public function VocabularyFormController::validate

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

Overrides EntityFormController::validate

File

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

Class

VocabularyFormController
Base form controller for vocabulary edit forms.

Namespace

Drupal\taxonomy

Code

public function validate(array $form, array &$form_state) {
  parent::validate($form, $form_state);

  // Make sure that the machine name of the vocabulary is not in the
  // disallowed list (names that conflict with menu items, such as 'list'
  // and 'add').
  // During the deletion there is no 'machine_name' key.
  if (isset($form_state['values']['machine_name'])) {

    // Do not allow machine names to conflict with taxonomy path arguments.
    $machine_name = $form_state['values']['machine_name'];
    $disallowed = array(
      'add',
      'list',
    );
    if (in_array($machine_name, $disallowed)) {
      form_set_error('machine_name', t('The machine-readable name cannot be "add" or "list".'));
    }
  }
}