Argument must be of type string, null given, in action on infolist component
I'm getting the error:
It seems that in the
InteractsWithInfolists
class, the $this->mountedInfolistActionsInfolist
property is not getting set. Can't seem to figure out what this is or how I would set it.
I've tried adding a name based on this somewhat related github issue: https://github.com/filamentphp/filament/issues/7630
I'm using an instance of Filament\Infolists\Components\Actions\Action
:
GitHub
Bug with anonymous actions on infolist · Issue #7630 · filamentphp/...
Package filament/filament Package Version v3.0.15 Laravel Version v10.18.0 Livewire Version No response PHP Version PHP 8.1 Problem description I followed the documents https://github.com/sbc640964...
Solution:Jump to solution
GitHub
arguments passed to action modal content missing · Issue #8763 · fi...
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 ...
25 Replies
I switched to using
Filament\Actions\Action
and now there's no error, but it also just doesn't do anything.
Not sure if there are additional steps I need to take to get a modal to work.
it seems like the action()
method doesn't work, it only responds if I use the url()
method, but I don't want to navigate to a new url, I just want to open a modal.
if anyone knows what I'm doing wrong, please clue me in. I'm beating my head against a wall over here.@hyphen81 I don't really use infolists, but are you sure this code is correct?
The syntax looks ...off? Maybe something like
Also, in your linked issue I see they are using
Ah no, didn't know it was a plugin.
I'm kind of borrowing from the Simple List Entry plugin. I needed a bit of a different styling on the front end, but it's the same basic concept.
@ChesterS I tried modifying my code to use the \InfoLists\Components\Actions\Action::make(), but then I get this error, which is kind of in line with what was going on in that github issue:
However, even just using the stock plugin, the Actions don't work as shown in the documentation.
I don't know if it's because rather than a regular infolist where there would be one action for the infolist, I have basically multiple "items" within the entry, and each one has a button.
I think that's why the fn($record) => [] syntax is needed so that each item has access to the record. I'm fumbling my way through it, so not confident on that.
I tried adding the record id to make each button unique, but that didn't do anything. They display just fine, they just don't do anything.
Do I have to have a method in my class to handle dispatching the modal? I thought that kind of happened automatically. This is a
Page
type class by the way that has my infolist in it.You need an action and a form on the Action (Button) to dispatch a modal.
ok, I added that, and it's not doing anything, although I'm not sure what should go in the
action()
method. I did verify that the mountAction()
method on the InteractsWithActions trait is getting called.
Looks ok here
So in the mountedAction method I'm logging some things:
The
$action
variable is empty though. So getMountedAction()
isn't doing anything.⬆️ That's from the InteractsWithActions trait
There aren't any
mountedActions
...getting closer..
I don't know how to mount actions. I thought I was doing that by doingAction::make()
.
What's crazy is, in the first line of that method, it's adding an item to the mountedActions
array, and in my log it's showing edit
for the name parameter, so it's there should be 1 item in the array when getMountedAction()
is called. This is very confusing.Ok, so I think the action must be getting called 4 times (?). I'm logging from inside the
getMountedAction
method and when I click the button, this is what's logged.I guess the last 2 are from when things re-hydrate and the mountAction gets called again (?).
Solution
GitHub
arguments passed to action modal content missing · Issue #8763 · fi...
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 ...
probably, this
argh, yeah that's probably it. thank you...hopefully I can implement the workaround mentioned.
If you manage to implement, don't hesitate to share. I didn't find a way myself 😦 Happy coding ! 🚀
Yeah, I ended up just using livewire components and dispatching an event. It works for my situation and this way I'm not wasting anymore time on it.
Ok, tanks and happy coding 🚀 I hope it get resolve someday 🙂
me too! it looks like the fix is close to being released..
oh that's good news ! What makes you say that ?
I thought it had been added to a release that was almost completed, but after looking again, I think I was wrong about that.
did you solve that error ?
Argument #1 ($name) must be of type string
?I don't think so, I believe I just went a different direction.