Error on action unmount when using arguments in ->record

I'm using the EditAction like this:
EditAction::make()
->record(fn (array $arguments) => Company::find($arguments['company']))
EditAction::make()
->record(fn (array $arguments) => Company::find($arguments['company']))
In Filament v4, the record method is sometimes called without any arguments, which leads to an error because the 'company' key is not defined. I've traced the error to this line in the Filament source: https://github.com/filamentphp/filament/blob/4cd8dd2934f8b43a1f6b720eeb84450f2bbe81bf/packages/actions/src/Concerns/InteractsWithActions.php#L672 It appears that Filament attempts to retrieve the record during the unmount phase, even when no arguments are passed. A workaround that avoids the error is:
EditAction::make()
->record(fn (array $arguments) => isset($arguments['company']) ? Company::find($arguments['company']) : null)
EditAction::make()
->record(fn (array $arguments) => isset($arguments['company']) ? Company::find($arguments['company']) : null)
I'm unsure if the missing arguments during unmount are intentional or a bug. I'm happy to provide a minimal reproduction repository if this behavior is considered bug.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?