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

35 messages · Page 1 of 1 (latest)

scenic pond
#

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

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')
                    // ])

                ]),
GitHub

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...

wheat valveBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

scenic pond
#

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.

scenic pond
#

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.

unkempt elm
#

@scenic pond I don't really use infolists, but are you sure this code is correct?

->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')
    // ])
]),
#

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))
  ]
noble onyx
unkempt elm
#

Ah no, didn't know it was a plugin.

scenic pond
#

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.

@unkempt elm 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
#

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.

rugged quest
scenic pond
#

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))
rugged quest
#

Looks ok here

scenic pond
#

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.

scenic pond
#

I guess the last 2 are from when things re-hydrate and the mountAction gets called again (?).

unkempt elm
#

probably, this

scenic pond
#

argh, yeah that's probably it. thank you...hopefully I can implement the workaround mentioned.

wheat valveBOT
unkempt elm
scenic pond
#

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.

unkempt elm
#

Ok, tanks and happy coding 🚀 I hope it get resolve someday 🙂

scenic pond
#

me too! it looks like the fix is close to being released..

unkempt elm
scenic pond
#

I thought it had been added to a release that was almost completed, but after looking again, I think I was wrong about that.

digital hazel
#

did you solve that error ? Argument #1 ($name) must be of type string ?