2

I'm using Filament to create a table. I have the following two functions in my Livewire class. The getTableRecordUrlUsing() function works as expected.

The getTableActions() function spawns an error page saying "Missing required parameter for [Route: recipe.show] [URI: recipe/{id}] [Missing parameter: id]."


    protected function getTableActions()
    {
        return [
            Action::make('edit')
                ->url(fn (Recipe $r): string => route('recipe.show', ['id' => $r])),
        ];
    }

    protected function getTableRecordUrlUsing()
    {
        return function (Recipe $r) {
            return route('recipe.show', ['id' => $r]);
        };
    }


One function works. The other doesn't. I'm out of ideas.

thc1967
  • 23
  • 1
  • 4

1 Answers1

6

Do not change closure parameter names in filament, try to rename $r to $record :

protected function getTableActions()
{
    return [
        Action::make('edit')
            ->url(fn (Recipe $record): string => route('recipe.show', ['id' => $record])),
    ];
}

...

Update: This will be no longer a problem in v3.

jade
  • 781
  • 12
  • 24