public function TaxonomyColor::colorInputBoxs in Fullcalendar View 8
Same name and namespace in other branches
- 8.3 src/TaxonomyColor.php \Drupal\fullcalendar_view\TaxonomyColor::colorInputBoxs()
- 8.2 src/TaxonomyColor.php \Drupal\fullcalendar_view\TaxonomyColor::colorInputBoxs()
- 6.x src/TaxonomyColor.php \Drupal\fullcalendar_view\TaxonomyColor::colorInputBoxs()
- 5.x src/TaxonomyColor.php \Drupal\fullcalendar_view\TaxonomyColor::colorInputBoxs()
Color input box for taxonomy terms of a vocabulary.
File
- src/
TaxonomyColor.php, line 26
Class
- TaxonomyColor
- Class TaxonomyColor.
Namespace
Drupal\fullcalendar_viewCode
public function colorInputBoxs($vid, array $defaultValues, $open = FALSE) {
// Taxonomy color details.
$elements = [
'#type' => 'details',
'#title' => $this
->t('Colors for Taxonomies'),
'#fieldset' => 'colors',
'#open' => $open,
'#prefix' => '<div id="color-taxonomies-div">',
'#suffix' => '</div>',
'#states' => [
// Only show this field when the 'vocabularies' is selected.
'invisible' => [
[
':input[name="style_options[vocabularies]"]' => [
'value' => '',
],
],
],
],
];
// Term IDs of the vocabulary.
$terms = $this
->getTermIds($vid);
if (isset($terms[$vid])) {
// Create a color box for each terms.
foreach ($terms[$vid] as $taxonomy) {
$color = isset($defaultValues[$taxonomy
->id()]) ? $defaultValues[$taxonomy
->id()] : '#3a87ad';
$elements[$taxonomy
->id()] = [
'#title' => $taxonomy->name->value,
'#default_value' => $color,
'#type' => 'color',
'#states' => [
// Only show this field when the 'tax_field' is selected.
'invisible' => [
[
':input[name="style_options[tax_field]"]' => [
'value' => '',
],
],
],
],
'#attributes' => [
'value' => $color,
'name' => 'style_options[color_taxonomies][' . $taxonomy
->id() . ']',
],
];
}
}
return $elements;
}