Skip to content

Commit 4fdbbff

Browse files
authored
Correctly store falsy startup variable values (#2305)
1 parent 2ed8916 commit 4fdbbff

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/Filament/Components/Forms/Fields/StartupVariable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function setUp(): void
4949

5050
$this->hintIcon(TablerIcon::Code, fn (StartupVariable $component) => implode('|', $component->getVariableRules()));
5151

52-
$this->helperText(fn (StartupVariable $component) => !$component->getVariableDesc() ? '' : $component->getVariableDesc());
52+
$this->helperText(fn (StartupVariable $component) => $component->getVariableDesc());
5353

5454
$this->rules(fn (StartupVariable $component) => $component->getVariableRules());
5555

@@ -70,7 +70,7 @@ public function getDefaultStateCasts(): array
7070
],
7171
StartupVariableType::Toggle => [
7272
...parent::getDefaultStateCasts(),
73-
new BooleanStateCast(false),
73+
new BooleanStateCast(false, true),
7474
],
7575
default => parent::getDefaultStateCasts()
7676
};

app/Filament/Server/Pages/Startup.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,16 @@ public static function canAccess(): bool
149149
return parent::canAccess() && user()?->can(SubuserPermission::StartupRead, Filament::getTenant());
150150
}
151151

152-
public function update(?string $state, ServerVariable $serverVariable): void
152+
public function update(null|string|bool $state, ServerVariable $serverVariable): void
153153
{
154154
if (!$serverVariable->variable->user_editable) {
155155
return;
156156
}
157157

158+
if (is_bool($state)) {
159+
$state = $state ? '1' : '0';
160+
}
161+
158162
$original = $serverVariable->variable_value;
159163

160164
try {

0 commit comments

Comments
 (0)