Tabs and tables together. Request for help.
Please help.
I have an application that does not use Panel Builder. Uses tables and forms as livewire components.
Is there any way for me to add infolist tabs above the table? This topic is very urgent for me. Please advise.
40 Replies
Can you clarify what you mean 'infolist tabs above the table'? You can add tabs above a table that change the table data (if that's what you want)
Thank you. How to add tabs above a table in the livewire component?
How and where should I define them?
https://filamentphp.com/docs/3.x/tables/adding-a-table-to-a-livewire-component
Update your component and add anything that's missing from the example bellow
In your template, add this above your table
There are probably other ways. Give it a try
You can probably replace
<x-filament-panels::resources.tabs />
with something else that renders tabs - or render them manually. This is just the simplest way I've foundIf it works, that would be great 🙂 I'll let you know. Thank you good man 🙂
The above error appears. I will be grateful for your help 🙂
What's your
getTabs
code?public function getTabs(): array
{
return [
'all' => Tab::make(('All')),
'anotherTab' => Tab::make(('Another tab'))
->modifyQueryUsing(fn (Builder $query) => $query->where('something', '=', true)),
];
}
Also, is that the whole file? Put the
<x-filament-panels::resources.tabs />
code inside the parent div
btw that will probably throw an error anyway. You can remove the anotherTab
part for nowSame
Is everything up to date? Filament 3, laravel etc?
yes
Updated today
Hmm that's weird. Can you remove the other livewire stuff from the page and see how it works ? (
livewire:layout
that are below the table etc)
also, can you share the rest of the component code?I have now prepared a clean file containing the table example from the documentation. I added the code for bookmarks. There are no errors in this release, but the table is displayed but the tabs are not.
This works? You have some unclosed elements (eg
<x-filament-panels::page
needs to be <x-filament-panels::page>
)🙂
This looks unrelated 🤔 Can you run regular cleanup step (clean cache/npm build etc/filament update etc)
The table was displayed. I added the "page" tag because I noticed it in the sources on github (I don't know why I didn't close the tag), but it doesn't change anything.
can you remove the
<x-filament-panels::page
stuff too?Gosh. This is a large, working project. Forms, notifications, tables and actions work. I just wanted to tabs 🙂
leave something simple like
yeah lot's of moving parts. most of it is boilerplate and you might not need everything
Without the "page" tag there is no error, the table is displayed, without tabs. There is an error with "page" that I pasted above.
Table works, no tabs. They are not found in the sources in the DOM tree either.
This is weird. This is pretty much the code I use and it works. How do you render the component?
I have something like
@livewire('my-table-with-tabs')
can you add something like
what about this
@dump($this->getCachedTabs())
?
Either way, I dunno mate. Try to copy the code from vendor/filament/filament/resources/views/components/resources/tabs.blade.php
and see if it works for you. You can render the tabs manually but it's a bit more code to do soOk that's probably why nothing shows 🤔
Can you add this method just to see if it works
❤️
This is weird. It should work without it. Maybe you have something that conflicts 🤔
It worked. Great thanks for your help. Should I somehow fix the code or leave this "workaround" (I guess)?
Anyway, up to you if you want to dig deeper.
There's nothing crazy. If you check the file I mentioned (
vendor/filament/filament/resources/views/components/resources/tabs.blade.php
and the HasTabs
concern you'll see what's going on
For some reason this return $this->cachedTabs ??= $this->getTabs();
doesn't work as expected for you
and as a result, this code in the template
returns false
and doesn't show anythingI'll leave with this workaround for now. I will test whether these tabs will also work in my Abstract classes. Could I call you sometime if I have any other problems in the future? 🙂
(Sorry for my bad English 😃 )
Just open another issue here and someone smarter might be around to help. Either way, I don't mind if you ping me - but I might be busy.
Good luck
@ChesterS Hi. Would you have any idea why modifyQueryUsing doesn't modify the query in the table? Or how should I do it? Thanks in advance for your help 🙂
$query = $this->modifyQueryWithActiveTab($query);
I did it and it works, but I don't know if it's state-of-the-art.