mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
mvc/OptionField type - fix regression in bc195308be , can't make choices static, unless we would serialize $data's payload first. to avoid further issues, just go back to always setting the values.
This commit is contained in:
parent
8228f5de5f
commit
b0f3e131f5
@ -34,26 +34,21 @@ namespace OPNsense\Base\FieldTypes;
|
||||
*/
|
||||
class OptionField extends BaseListField
|
||||
{
|
||||
/**
|
||||
* @var string static option list, no need to parse the same structure multiple times
|
||||
*/
|
||||
private static $internalCacheOptionList = [];
|
||||
|
||||
/**
|
||||
* setter for option values
|
||||
* @param $data
|
||||
*/
|
||||
public function setOptionValues($data)
|
||||
{
|
||||
if (is_array($data) && empty(self::$internalCacheOptionList)) {
|
||||
self::$internalCacheOptionList = [];
|
||||
if (is_array($data)) {
|
||||
$this->internalOptionList = [];
|
||||
// copy options to internal structure, make sure we don't copy in array structures
|
||||
foreach ($data as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
self::$internalCacheOptionList[$key] = gettext($value);
|
||||
$this->internalOptionList[$key] = gettext($value);
|
||||
} else {
|
||||
foreach ($value as $subkey => $subval) {
|
||||
self::$internalCacheOptionList[$subkey] = [
|
||||
$this->internalOptionList[$subkey] = [
|
||||
'value' => $subval,
|
||||
'optgroup' => $key
|
||||
];
|
||||
@ -61,6 +56,5 @@ class OptionField extends BaseListField
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->internalOptionList = self::$internalCacheOptionList;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user