protected static function ShsTermSelect::buildTermOptions in Webform Simple Hierarchical Select 8
Build a list of term options for provided vocabulary.
Parameters
string $vid: Vocabulary id.
Return value
array List of term options.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
2 calls to ShsTermSelect::buildTermOptions()
- ShsTermSelect::buildCachedTermOptions in src/
Element/ ShsTermSelect.php - Build a cached list of term options for provided vocabulary.
- ShsTermSelect::buildOptions in src/
Element/ ShsTermSelect.php - Build a list of term options for provided vocabulary.
File
- src/
Element/ ShsTermSelect.php, line 270
Class
- ShsTermSelect
- Provides a webform element for an shs term select menu.
Namespace
Drupal\webform_shs\ElementCode
protected static function buildTermOptions($vid) {
$options = [];
/** @var \Drupal\taxonomy\TermStorageInterface $taxonomy_storage */
$taxonomy_storage = \Drupal::entityTypeManager()
->getStorage('taxonomy_term');
$terms = $taxonomy_storage
->loadTree($vid);
foreach ($terms as $item) {
$options[$item->tid] = $item->name;
}
return $options;
}