Fix for option group validation

This commit is contained in:
nathan 2022-12-20 15:45:50 -07:00
parent 2748376f6f
commit 3e54b25a91
2 changed files with 8 additions and 2 deletions

View File

@ -169,7 +169,13 @@ class Select extends Etemplate\Widget
{
if ($child->type == 'option') $allowed[] = (string)$child->attrs['value'];
}
$allowed = array_map('strval', $allowed);
// Make sure values are strings so they match, also handling option groups
$stringified = array();
array_walk_recursive($allowed, function ($a, $b) use (&$stringified) {
if($b == 'value') $stringified[] = $a;
else if (is_int($b)) $stringified[] = strval($a);
});
$allowed = $stringified;
// Add empty as an option, we check for required value later
$allowed[] = '';

View File

@ -363,7 +363,7 @@ class preferences_hooks
'type' => 'multiselect',
'label' => 'Permanent time zone selection',
'name' => 'tz_selection',
'values' => $tzs ? array_merge(...array_values($tzs)) : null, // only flat arrays supported
'values' => $tzs
'help' => 'Please select timezones, you want to be able to quickly switch between. Switch is NOT shown, if less then two are selected.',
'xmlrpc' => True,
'admin' => False,