F
Filament16mo ago
josef

Toggle in Action does not respect default state

I'm trying to customize the ReplicateAction on a table by showing toggles that allow the user to (de-)select data that is to be replicated. I want all the toggles to be on by default, but using default(true) on the toggles has no visible effect. They present as false. Code:
Tables\Actions\ReplicateAction::make()
->form([
Forms\Components\Fieldset::make()
->schema([
Forms\Components\Toggle::make('prices')
->default('true'),
])
])
Tables\Actions\ReplicateAction::make()
->form([
Forms\Components\Fieldset::make()
->schema([
Forms\Components\Toggle::make('prices')
->default('true'),
])
])
Result:
Solution:
try ```php Tables\Actions\ReplicateAction::make() ->mountUsing(fn (\Filament\Forms\ComponentContainer $form) => $form->fill()) ->form([...
Jump to solution
5 Replies
Andrew Wallo
Andrew Wallo16mo ago
Does the ToggleButton component work for this? Just curious
josef
josefOP16mo ago
First thing I tried 😄 no, it doesn't, unfortunately
Andrew Wallo
Andrew Wallo16mo ago
Hmm weird then I guess it’s specific to all Boolean components? Did you try a button group with options yes and no, with default yes?
Solution
LeandroFerreira
LeandroFerreira16mo ago
try
Tables\Actions\ReplicateAction::make()
->mountUsing(fn (\Filament\Forms\ComponentContainer $form) => $form->fill())
->form([
Forms\Components\Fieldset::make()
->schema([
Forms\Components\Toggle::make('prices')
->default(true),
])
])
Tables\Actions\ReplicateAction::make()
->mountUsing(fn (\Filament\Forms\ComponentContainer $form) => $form->fill())
->form([
Forms\Components\Fieldset::make()
->schema([
Forms\Components\Toggle::make('prices')
->default(true),
])
])
josef
josefOP16mo ago
Thanks, that did it
Want results from more Discord servers?
Add your server