function farm_id_tag_type_allowed_values in farmOS 2.x
Allowed values callback function for the ID tag type field.
Parameters
string $bundle: The asset bundle to get allowed values for.
Return value
array Returns an array of allowed values for use in form select options.
1 call to farm_id_tag_type_allowed_values()
- IdTagWidget::formElement in modules/
core/ id_tag/ src/ Plugin/ Field/ FieldWidget/ IdTagWidget.php - Returns the form for a single field widget.
File
- modules/
core/ id_tag/ farm_id_tag.module, line 43 - ID tag module.
Code
function farm_id_tag_type_allowed_values($bundle) {
/** @var \Drupal\farm_id_tag\Entity\FarmIDTagTypeInterface[] $types */
$types = \Drupal::entityTypeManager()
->getStorage('tag_type')
->loadMultiple();
$allowed_values = [];
foreach ($types as $id => $type) {
$bundles = $type
->getBundles();
if (empty($bundles) || in_array($bundle, $bundles)) {
$allowed_values[$id] = $type
->getLabel();
}
}
return $allowed_values;
}