Skip to content

Commit

Permalink
ChannelForm: Type bool (checkbox) option must be stored as bool in db
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jan 30, 2025
1 parent aa74a5e commit 02155b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions application/forms/ChannelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down Expand Up @@ -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] = '';
Expand Down

0 comments on commit 02155b2

Please sign in to comment.