Using an Infolist-Action with another infolist in it.

I am Building an infolist on my OrderResource view page. For the Client field in my infolist I want to add a prefix/suffix/hint Action. This action should open a modal displaying additional client Information. I can add my client infolist using the infolist() method on the Action but I can’t seem to find the methods for setting the record or state. I therefore get an exception when clicking the action link. How can I set the record for my modal infolist?
9 Replies
krekas
krekas5w ago
Can't you pass record to the action? Like it is in the docs for almost any example
Samus_Aran
Samus_Aran5w ago
@krekas No. That's the confusing part. Method Filament\Infolists\Components\Actions\Action::record does not exist.
krekas
krekas5w ago
show your code
Samus_Aran
Samus_Aran5w ago
In OrderResource.php:
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
Infolists\Components\TextEntry::make('client.name')
->prefixAction(fn($record) => Action::make('copyCostToPrice')
->icon('heroicon-m-clipboard')
->record($record->client) // <- this doesn't exist
->infolist([
Infolists\Components\TextEntry::make('email'),
Infolists\Components\TextEntry::make('phone')
])
),
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
Infolists\Components\TextEntry::make('client.name')
->prefixAction(fn($record) => Action::make('copyCostToPrice')
->icon('heroicon-m-clipboard')
->record($record->client) // <- this doesn't exist
->infolist([
Infolists\Components\TextEntry::make('email'),
Infolists\Components\TextEntry::make('phone')
])
),
]);
}
@krekas a state() method is also not available 🤔
krekas
krekas5w ago
you want to open infolist modal inside infolist? also, that's not how you pass a record to the action and where did you even saw record() or state()?
Samus_Aran
Samus_Aran5w ago
@krekas Yes, I have an Infolist and I want to use a prefixAction on a TextEntry to open a modal that contains another infolist with more information. And since i have the infolist() method available on this Action to pass an infolist into it, I would assume that there should also be a way to provide the data to the infolist @krekas I now did the following workaround:
TextEntry::make('client.name')
->prefixAction(fn($record) => Action::make('clientDetails')
->icon('heroicon-m-clipboard')
->modalContent(fn($record) => view('client.show', ['client' => $record->client]))
)
TextEntry::make('client.name')
->prefixAction(fn($record) => Action::make('clientDetails')
->icon('heroicon-m-clipboard')
->modalContent(fn($record) => view('client.show', ['client' => $record->client]))
)
The Blade View client.show then renders a Livewire component with an Infolist 🤷‍♂️
krekas
krekas5w ago
please stop tagging like that for every message
Samus_Aran
Samus_Aran5w ago
sorry