F
Filament16mo ago
Abi

Can a custom infolist ViewEntry have a FilamentTable?

I am creating a custom infolist viewentry and on the ViewEntry class I tried to add the HasTable and HasForms but can't seem to get it to work. Any advice?
14 Replies
krekas
krekas16mo ago
do you really expect someone to help you if you don't show code?
Patrick Boivin
Patrick Boivin16mo ago
You may be able to do it with a custom Livewire component. The ViewEntry renders a Blade view, the Blade view includes the Livewire component, the component implements the Table. Something to try.
Abi
AbiOP16mo ago
@pboivin Thank you. I already tried this.
ViewEntry::make('familyMembers')
->view('infolists.components.user.family-members')
->viewData([
'user' => fn($record) => $record,
])
->columnSpanFull()
->hiddenLabel()
ViewEntry::make('familyMembers')
->view('infolists.components.user.family-members')
->viewData([
'user' => fn($record) => $record,
])
->columnSpanFull()
->hiddenLabel()
But I get an error
Property [$table] not found on component: [app.filament.resources.c-r-m.customer-resource.pages.view-customer]
Property [$table] not found on component: [app.filament.resources.c-r-m.customer-resource.pages.view-customer]
and this is what I have on the Livewire Component
class FamilyMembers extends Entry implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;

protected string $view = 'infolists.components.user.family-members';

public User $user;

public function table(Table $table): Table
{
return $table
->query($this->user->familyMembers()->newQuery())
->columns([
TextColumn::make('name')
]);
}
}
class FamilyMembers extends Entry implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;

protected string $view = 'infolists.components.user.family-members';

public User $user;

public function table(Table $table): Table
{
return $table
->query($this->user->familyMembers()->newQuery())
->columns([
TextColumn::make('name')
]);
}
}
and this is the blade
<div class="mt-8 flow-root">
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="inline-block w-full py-2 align-middle sm:px-6 lg:px-8">
{{$this->table}}
</div>
</div>
</div>
<div class="mt-8 flow-root">
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="inline-block w-full py-2 align-middle sm:px-6 lg:px-8">
{{$this->table}}
</div>
</div>
</div>
not sure why I get the error on the View Page of the resource and not on the livewire component
krekas
krekas16mo ago
You are using table wrong. Check the docs how to use it
Abi
AbiOP16mo ago
@krekas I did and here is what I see in the docs https://filamentphp.com/docs/3.x/tables/adding-a-table-to-a-livewire-component#adding-the-table Why not just help with what is wrong and stop being a dick about it. I see you doing the same on the github discussions as well. If you cannot help why be here.
Abi
AbiOP16mo ago
@pboivin any help is appreciated.
krekas
krekas16mo ago
Wait you don't have any columns in your table first
Abi
AbiOP16mo ago
but that still doesn't change the error. I have already tried that.
krekas
krekas16mo ago
In your familymembers the view provided is different from the on in the error
Abi
AbiOP16mo ago
exactly, that is what I mentioned above as to why I am getting the error for the View page of the resource and not the livewire component the view() method takes the livewire view, so is there a way to set the Livewire component class instead of the view? @leandro_ferreira any advice on this issue?
krekas
krekas16mo ago
wait you made a custom view right? with php artisan make:infolist-layout? so shouldn't you call it instead of view?
LeandroFerreira
LeandroFerreira16mo ago
Entry isn't a Livewire component
Patrick Boivin
Patrick Boivin16mo ago
@.abishek The ViewEntry should render a regular Blade view, and then the Blade view should contain the Livewire component.
Abi
AbiOP16mo ago
ok, let me try that @pboivin thank you that worked. appreciate the help
Want results from more Discord servers?
Add your server