action method not working on a standalone Action
I have the following code and the
action
method doesn't get executed.
and the blade content is the following
10 Replies
Ref to this docs https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#passing-action-arguments, it should be like
{{ ($this->addToCart)(['productId'=>$item->id]) }}
Notice Action
is removedI tried that, still have the same issue
The modal shows up correctly, but the action method is never getting executed. The action is actually inside a
@foreach
loop, I thought may be that could be the issue, so I removed it from the loop and it still doesn't workDid you try
dd($data)
or ray($data)
instead of $this
yes, tried both
nothing, it just closes the modal, it doesn't refresh the page. I checked the network calls on the dev tools. No errors
all the validations seem to work correctly in the modal form, but the submit button just closes the modal and doesn't execute the
action
methodDid you put your action inside public function like the docs, like this
Yes
every other functionality of that action method works except for the
action
method of the Action
class
the modal opens correctly, the validation for the Select
component works correctly, just not the ->action
methodIn the docs, they put
->action(function (array $arguments)
, can you try with $arguments
.. This is stand alone Action and I don't have time to reproduce rn.. other than this I don't have any idea thothey have both
$arguments
and $data
, tried both
ok, found the issue and wasted so much time
it was action(fn($data) => function () {
I don't know why I created a fn
and pointed to an function
. That was just so stupid to not notice it at all..
changed it to action(function ($data) {
and it workedhaha.. learn from mistake 😆
Thanks for the help and your time