From 1079dc608e53eb2a6e04e8cad37078f447b2b050 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Jul 2024 16:19:46 +0200 Subject: [PATCH] ChannelForm: Store cleared default options as empty string --- application/forms/ChannelForm.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/application/forms/ChannelForm.php b/application/forms/ChannelForm.php index 0394e89c..7b03b7e1 100644 --- a/application/forms/ChannelForm.php +++ b/application/forms/ChannelForm.php @@ -397,17 +397,19 @@ protected function fromCurrentLocale(array $localeMap): ?string */ private function filterConfig(array $config): array { - return array_filter( - $config, - function ($configItem, $key) { - if (isset($this->defaultChannelOptions[$key])) { - return $this->defaultChannelOptions[$key] !== $configItem; + foreach ($config as $key => $value) { + if (isset($this->defaultChannelOptions[$key])) { + if ($value === null) { + $config[$key] = ''; + } elseif ($this->defaultChannelOptions[$key] === $value) { + unset($config[$key]); } + } elseif ($value === null) { + unset($config[$key]); + } + } - return $configItem !== null; - }, - ARRAY_FILTER_USE_BOTH - ); + return $config; } /**