Skip to content

Commit 23e710a

Browse files
ChannelForm: Type bool (checkbox) option must be stored as bool in db (#289)
fixes #267
2 parents ede7734 + 474b417 commit 23e710a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

application/forms/ChannelForm.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ protected function getElementOptions(array $elementConfig): array
334334
'label' => $this->fromCurrentLocale($elementConfig['label'])
335335
];
336336

337+
if ($elementConfig['type'] === 'bool') {
338+
$options['checkedValue'] = 'checked';
339+
$options['uncheckedValue'] = 'unchecked';
340+
}
341+
337342
if (isset($elementConfig['help'])) {
338343
$options['description'] = $this->fromCurrentLocale($elementConfig['help']);
339344
}
@@ -398,6 +403,10 @@ protected function fromCurrentLocale(array $localeMap): ?string
398403
private function filterConfig(array $config): array
399404
{
400405
foreach ($config as $key => $value) {
406+
if (in_array($value, ['checked', 'unchecked'], true)) {
407+
$config[$key] = $value === 'checked';
408+
}
409+
401410
if (isset($this->defaultChannelOptions[$key])) {
402411
if ($value === null) {
403412
$config[$key] = '';

0 commit comments

Comments
 (0)