Closed wychoong closed 9 months ago
after some source dive, this is due to how filament handle the action mounting.
there are 2 issues in it:
to determine whether an action contain modal content, action will call getModalContent
once
https://github.com/filamentphp/filament/blob/f69bc07143f9752f41d96b31de8dbe3b68979ebb/packages/actions/src/Concerns/InteractsWithActions.php#L187-L200
thus in the log it shows multiple calls, 1 for checking and 1 for actual content rendering. with caching in getModalContent
will be a quick and easy way, or add a new hasModalContent
. this will bring the calls down to 2, and the second call is mounting action
mounting action
in <x-filament-actions::modals />
the action is fetch as below
$action = $this->getMountedAction();
however here is where the issue why $arguments
is empty, it doesn't mount $livewire->mountedActionsArguments
a workaround will be
->modalContent(function ($arguments, $action) {
$arguments = Arr::last($this->mountedActionsArguments);
return view('components.modal-content', [
'params' => 'params',
'arguments' => $arguments,
]);
})
this works but its not ideal, and should be fixed
had the same issue and this worked for me
$arguments = Arr::last($this->mountedActionsArguments);
I believe this was fixed a couple of weeks ago
I believe this was fixed a couple of weeks ago
hey @danharrin thanks for the fix, can confirmed its fixed.
as mentioned in this issue there is also another issue where Action->modalContent
is being called multiple times, which can be tested with the issue repo with this minor addition
->modalContent(function ($arguments, $action) {
Log::info($action->getname(), [$arguments, $action->getArguments()]);
})
can you reopen this and rename the title? or should a new issue with same repo to be opened?
please rename it :)
please rename it :)
thanks, I have updated the issue repo as well
Should be fixed by #10143, please confirm
Should be fixed by #10143, please confirm
Can confirm its fixed. Thanks!
Package
filament/filament
Package Version
3.0.62
Laravel Version
10.25.1
Livewire Version
3.0.5
PHP Version
8.1.23
Problem description
when passing action arguments to modal content view it become empty
a behaviour that is observed is
Action->modalContent
is being called 4 times and only the first call contain the argumentsExpected behavior
only call one time and the arguments are passed to the view
Steps to reproduce
clone the repo and go to "Action Test" page
Reproduction repository
https://github.com/wychoong/filament-test/tree/passing-arguments-to-action-modal-view
Relevant log output
No response