Skip to content
Snippets Groups Projects
Commit 0202080d authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Issue #3465478 by dieterholvoet: 'Undefined array key "vid"' when adding views filter

parent 7bb6d0ba
Branches
Tags
1 merge request!12Check if the vid array key is set
......@@ -60,17 +60,16 @@ class TaxonomyEnumReference extends ManyToOne {
return $this->valueOptions;
}
if (!$vid = $this->options['vid']) {
$this->valueOptions = [];
return;
if (empty($this->options['vid'])) {
return $this->valueOptions = [];
}
$vid = $this->options['vid'];
$vocabulary = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->load($vid);
$enumName = $vocabulary->getThirdPartySetting('taxonomy_enum', 'enum_name');
if (!enum_exists($enumName) || !method_exists($enumName, 'from')) {
$this->valueOptions = [];
return;
return $this->valueOptions = [];
}
$termStorage = $this->entityTypeManager
......@@ -81,7 +80,7 @@ class TaxonomyEnumReference extends ManyToOne {
->execute();
$terms = $termStorage->loadMultiple($termIds);
$this->valueOptions = array_reduce(
return $this->valueOptions = array_reduce(
$terms,
function (?array $options, TermInterface $term) {
$options[$term->get('machine_name')->value] = $term->label();
......@@ -110,7 +109,7 @@ class TaxonomyEnumReference extends ManyToOne {
},
Vocabulary::loadMultiple(),
),
'#default_value' => $this->options['vid'],
'#default_value' => $this->options['vid'] ?? NULL,
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment