Taxonomy form autocomplete, Create taxonomy term field with FAPI
Simple taxonomy autocomplete field.
Example:$form['tagtest'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => 'Taxonomy Term',
];
Example:$form['tagtest'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => 'Taxonomy Term',
];
To Show more than 100 terms in taxonomy administration (overview) page, You must set the terms_per_page_admin of taxonomy.settings.
Example : Create a terom of the vocabulary 'test_vocabulary'
//Minimum$term = \Drupal\taxonomy\Entity\Term::create([
'vid' => 'test_vocabulary',
'name' => 'My tag',
]);
$term->save();
Using entityQuery, you can get the taxonomy terms of a particular vocabulary.
In drupal 8, this retrun taxonomy vocabularies as an array.
$vocabularies = \Drupal\taxonomy\Entity\Vocabulary::loadMultiple();