Only arrays and Traversables can be unpacked
My code is like this:
After I click on confirm, it gives me the following error:
Only arrays and Traversables can be unpacked
Where am I wrong?
Thank you9 Replies
Dispatch doesn’t use an array anymore. It uses named arguments.
Ie,
$this->dispatch('post-created', title: $post->title);
now get this
Filament\Actions\StaticAction::dispatch(): Argument #2 ($data) must be of type Closure|array, int given,
You have to name it.
id: $this->reply->id
Looks like filament is complaining though, so [‘id’ => $this->reply->id]
So if with this
->dispatch('doDelete', ['id'=>$this->reply->id]),
get error Only arrays and Traversables can be unpacked
If I trade with this ->dispatch('doDelete', $this->reply->id)
get this error Filament\Actions\StaticAction::dispatch(): Argument #2 ($data) must be of type Closure|array, int given
I do not understand,
Anyway, thanks for the answers, I'll try tomorrow after I get some sleepYea. Something is off. It’s telling you to use an array but not accepting an array:
Are you importing/using the right Action?
this
Hey, I'm currently experiencing this as well. What was the fix?
@stanwarri no
i use
deleteAction(): Action
to get aroundOh ok. Passing an array like this worked for me
->dispatch('doDeleteComment', ['commentId' => $commentId]),