Argument must be of type string, null given, in action on infolist component

I'm getting the error:
App\Filament\App\Pages\Locations\MonthEndTasks::getInfolist(): Argument #1 ($name) must be of type string, null given, called in /var/www/html/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 257
App\Filament\App\Pages\Locations\MonthEndTasks::getInfolist(): Argument #1 ($name) must be of type string, null given, called in /var/www/html/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 257
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:
MonthEndTaskEntry::make('test')
->getStateUsing(MonthEndTask::all()->take(2))
->itemDescription('item description here')
->itemIcon('heroicon-m-user')
->itemIconColor('secondary')
->itemLabel(fn (MonthEndTask $record) => $record->user->fullName)
->itemActions(fn ($record) => [
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])

]),
MonthEndTaskEntry::make('test')
->getStateUsing(MonthEndTask::all()->take(2))
->itemDescription('item description here')
->itemIcon('heroicon-m-user')
->itemIconColor('secondary')
->itemLabel(fn (MonthEndTask $record) => $record->user->fullName)
->itemActions(fn ($record) => [
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])

]),
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:
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 ...
Jump to solution
23 Replies
Jon Mason
Jon MasonOP13mo ago
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.
ChesterS
ChesterS13mo ago
@hyphen81 I don't really use infolists, but are you sure this code is correct?
->itemActions(fn ($record) => [
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])

]),
->itemActions(fn ($record) => [
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])

]),
The syntax looks ...off? Maybe something like
->itemActions([
Action::make('something')->action(fn($record) => ...), // In case you need the record
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])
]),
->itemActions([
Action::make('something')->action(fn($record) => ...), // In case you need the record
Action::make('edit')
// ->form([
// TextEntry::make('title')
// ])
]),
Also, in your linked issue I see they are using
Infolists\Components\Actions::make([ // <- This one, instead of just an array
Infolists\Components\Actions\Action::make('Edit')
->form(fn($form) => static::form($form))
]
Infolists\Components\Actions::make([ // <- This one, instead of just an array
Infolists\Components\Actions\Action::make('Edit')
->form(fn($form) => static::form($form))
]
jouni.i
jouni.i13mo ago
Filament
Simple List Entry by Georges OLIVARES - Filament
Add Lists to your Infolist page
ChesterS
ChesterS13mo ago
Ah no, didn't know it was a plugin.
Jon Mason
Jon MasonOP13mo ago
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:
App\Filament\App\Pages\Locations\MonthEndTasks::getInfolist(): Argument #1 ($name) must be of type string, null given, called in /var/www/html/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 257
App\Filament\App\Pages\Locations\MonthEndTasks::getInfolist(): Argument #1 ($name) must be of type string, null given, called in /var/www/html/vendor/filament/infolists/src/Concerns/InteractsWithInfolists.php on line 257
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.
Jon Mason
Jon MasonOP13mo ago
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.
No description
Jon Mason
Jon MasonOP13mo ago
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.
toeknee
toeknee13mo ago
You need an action and a form on the Action (Button) to dispatch a modal.
Jon Mason
Jon MasonOP13mo ago
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.
Action::make('edit')->form([
TextInput::make('title')
])->action(fn ($record) => Log::debug($record))
Action::make('edit')->form([
TextInput::make('title')
])->action(fn ($record) => Log::debug($record))
toeknee
toeknee13mo ago
Looks ok here
Jon Mason
Jon MasonOP13mo ago
So in the mountedAction method I'm logging some things: The $action variable is empty though. So getMountedAction() isn't doing anything.
No description
Jon Mason
Jon MasonOP13mo ago
⬆️ 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.
Jon Mason
Jon MasonOP13mo ago
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.
No description
Jon Mason
Jon MasonOP13mo ago
I guess the last 2 are from when things re-hydrate and the mountAction gets called again (?).
Solution
zoomZoom
zoomZoom13mo ago
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 ...
zoomZoom
zoomZoom13mo ago
probably, this
Jon Mason
Jon MasonOP13mo ago
argh, yeah that's probably it. thank you...hopefully I can implement the workaround mentioned.
zoomZoom
zoomZoom13mo ago
If you manage to implement, don't hesitate to share. I didn't find a way myself 😦 Happy coding ! 🚀
Jon Mason
Jon MasonOP13mo ago
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.
zoomZoom
zoomZoom13mo ago
Ok, tanks and happy coding 🚀 I hope it get resolve someday 🙂
Jon Mason
Jon MasonOP13mo ago
me too! it looks like the fix is close to being released..
zoomZoom
zoomZoom13mo ago
oh that's good news ! What makes you say that ?
Jon Mason
Jon MasonOP13mo ago
I thought it had been added to a release that was almost completed, but after looking again, I think I was wrong about that.
Want results from more Discord servers?
Add your server