F
Filament5mo ago
Arrow

How to display infolist in a table column action with a relation record.

I want to display an infolist when a user clicks a column. I can easily do that using ViewAction. However, instead of the record iteself, I want to set the $record->customer as the infolist model. Is there something similar to fillForm for infolists?
TextColumn::make('name')
->action(function (HasTable $livewire, ?ExpiryReport $record) {
return ViewAction::make('View Customer')
->record($record->customer)
->infolist([
TextEntry::make('CRN')
TextEntry::make('NAME')
->label('Name'),
TextEntry::make('ADRS')
->label('Address'),
TextEntry::make('parentCrn')
->label('Parent'),
TextEntry::make('info.code')
->label('Code'),
])
->slideOver();
})
TextColumn::make('name')
->action(function (HasTable $livewire, ?ExpiryReport $record) {
return ViewAction::make('View Customer')
->record($record->customer)
->infolist([
TextEntry::make('CRN')
TextEntry::make('NAME')
->label('Name'),
TextEntry::make('ADRS')
->label('Address'),
TextEntry::make('parentCrn')
->label('Parent'),
TextEntry::make('info.code')
->label('Code'),
])
->slideOver();
})
Solution:
maybe ```php TextColumn::make('name') ->action(...
Jump to solution
3 Replies
Solution
LeandroFerreira
LeandroFerreira5mo ago
maybe
TextColumn::make('name')
->action(
ViewAction::make('view_customer')
->infolist([
TextEntry::make('customer.CRN')
...
])
)
TextColumn::make('name')
->action(
ViewAction::make('view_customer')
->infolist([
TextEntry::make('customer.CRN')
...
])
)
?
Arrow
Arrow5mo ago
That worked! thank you!! 🥰
Arrow
Arrow5mo ago
@Leandro Ferreira Is there a way to filter the relation query with a scope or modifying the query?
I have the following relationship: $record->customer->receipts I only want to fetch the current years receipts only and show via RepeatableEntry field
RepeatableEntry::make('customer.payments')
->columns(3)
->schema([
TextEntry::make('reference_no'),
TextEntry::make('payment_date')->date(),
TextEntry::make('amount_paid'),
])
])
RepeatableEntry::make('customer.payments')
->columns(3)
->schema([
TextEntry::make('reference_no'),
TextEntry::make('payment_date')->date(),
TextEntry::make('amount_paid'),
])
])