F
Filament13mo ago
Niek

Form Wizard with dynamic enabled/disabled submit button

I have a Filament Resource Form for creating a record. This Form contains a Wizard with a few steps. In the last step I need the submit button only to be enabled if a checkbox is checked. I use the function getSubmitFormAction(): public function getSubmitFormAction(): \Filament\Actions\Action { return parent::getSubmitFormAction() ->disabled(function (Forms\get $get) { return $get('confirm') == false; }); } Apparently this does not work: Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization This makes sense to me, but how do I achieve the submit button to be enabled only if the checkbox is checked? Any help would be very appreciated
Solution:
make sure the checkbox is live()
Jump to solution
4 Replies
Solution
Dan Harrin
Dan Harrin13mo ago
make sure the checkbox is live()
Dan Harrin
Dan Harrin13mo ago
->disabled(! $this->data['confirm'])
Niek
NiekOP13mo ago
That worked! Thank you so much.
Niek
NiekOP13mo ago
This worked, but with a slightly modified version: ->disabled( function () { return $this->data['confirm'] == false; }); Or ->disabled(! ($this->data['confirm'] ?? false));
Want results from more Discord servers?
Add your server