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
4 Replies
Solution
make sure the checkbox is live()
->disabled(! $this->data['confirm'])
That worked! Thank you so much.
This worked, but with a slightly modified version:
->disabled( function () {
return $this->data['confirm'] == false;
});
Or
->disabled(! ($this->data['confirm'] ?? false));