Skip to content
Snippets Groups Projects
Commit a711baf0 authored by Mikael Meulle's avatar Mikael Meulle Committed by Pierre Dureau
Browse files

Issue #3503141 by pdureau, hproustacx, g4mbini,...

Issue #3503141 by pdureau, hproustacx, g4mbini, just_like_good_vibes: EnumTrait::getEnumOptions() is not returrning enum values
parent 35a389a2
No related branches found
No related tags found
1 merge request!334Issue #3503141 by pdureau, hproustacx, g4mbini, just_like_good_vibes: EnumTrait::getEnumOptions() is not returrning enum values
Pipeline #410345 passed
......@@ -15,14 +15,13 @@ trait EnumTrait {
* Get form element options from enumeration.
*/
protected static function getEnumOptions(array $definition): array {
$values = array_combine($definition['enum'], $definition['enum']);
foreach ($values as $key => $label) {
if (is_string($label)) {
$values[$key] = ucwords($label);
}
}
$values = array_combine(
$definition['enum'],
array_map(static function ($value) {
return is_string($value) ? ucwords($value) : $value;
}, $definition['enum']));
if (!isset($definition['meta:enum'])) {
return array_values($values);
return $values;
}
$meta = $definition['meta:enum'];
// Remove meta:enum items not found in options.
......@@ -37,7 +36,7 @@ trait EnumTrait {
* Get allowed values from enumeration.
*/
protected static function getAllowedValues(array $definition): array {
return array_values(static::getEnumOptions($definition));
return array_keys(static::getEnumOptions($definition));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment