From 97c6fa554d0566c3dcb1308c02469b6b78bde9b1 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Thu, 30 Jan 2025 10:06:15 +0100 Subject: [PATCH] ChannelForm: Type bool (checkbox) option must be stored as bool in db --- application/forms/ChannelForm.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/application/forms/ChannelForm.php b/application/forms/ChannelForm.php index 7b03b7e1..087e6845 100644 --- a/application/forms/ChannelForm.php +++ b/application/forms/ChannelForm.php @@ -334,6 +334,11 @@ protected function getElementOptions(array $elementConfig): array 'label' => $this->fromCurrentLocale($elementConfig['label']) ]; + if ($elementConfig['type'] === 'bool') { + $options['checkedValue'] = 'checked'; + $options['uncheckedValue'] = 'unchecked'; + } + if (isset($elementConfig['help'])) { $options['description'] = $this->fromCurrentLocale($elementConfig['help']); } @@ -398,6 +403,10 @@ protected function fromCurrentLocale(array $localeMap): ?string private function filterConfig(array $config): array { foreach ($config as $key => $value) { + if (in_array($value, ['checked', 'unchecked'])) { + $config[$key] = $value === 'checked'; + } + if (isset($this->defaultChannelOptions[$key])) { if ($value === null) { $config[$key] = '';