function TaxonomyController::addForm

Same name in other branches
  1. 9 core/modules/taxonomy/src/Controller/TaxonomyController.php \Drupal\taxonomy\Controller\TaxonomyController::addForm()
  2. 10 core/modules/taxonomy/src/Controller/TaxonomyController.php \Drupal\taxonomy\Controller\TaxonomyController::addForm()
  3. 11.x core/modules/taxonomy/src/Controller/TaxonomyController.php \Drupal\taxonomy\Controller\TaxonomyController::addForm()

Returns a form to add a new term to a vocabulary.

Parameters

\Drupal\taxonomy\VocabularyInterface $taxonomy_vocabulary: The vocabulary this term will be added to.

Return value

array The taxonomy term add form.

1 string reference to 'TaxonomyController::addForm'
taxonomy.routing.yml in core/modules/taxonomy/taxonomy.routing.yml
core/modules/taxonomy/taxonomy.routing.yml

File

core/modules/taxonomy/src/Controller/TaxonomyController.php, line 24

Class

TaxonomyController
Provides route responses for taxonomy.module.

Namespace

Drupal\taxonomy\Controller

Code

public function addForm(VocabularyInterface $taxonomy_vocabulary) {
    $term = $this->entityTypeManager()
        ->getStorage('taxonomy_term')
        ->create([
        'vid' => $taxonomy_vocabulary->id(),
    ]);
    return $this->entityFormBuilder()
        ->getForm($term);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.