#Tabs and tables together. Request for help.

55 messages · Page 1 of 1 (latest)

fervent drift
#

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.

torpid hollyBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

coral garnet
fervent drift
#

Thank you. How to add tabs above a table in the livewire component?

#

How and where should I define them?

coral garnet
#

Update your component and add anything that's missing from the example bellow

class ReminderModal extends Component implements HasActions, HasForms, HasTable
{
    use HasTabs;
    use InteractsWithActions; // Might not need this
    use InteractsWithForms;
    use InteractsWithTable {
        makeTable as makeBaseTable;
    }

    public function mount(): void
    {
        $this->activeTab = 'all';
    }

    public function getRenderHookScopes(): array // This is only needed because it complains
    {
        return [static::class];
    }

    public function getTabs(): array
    {
        return [
            'all' => Tab::make(__('All')),
            'anotherTab' => Tab::make(__('Another tab'))
                ->modifyQueryUsing(fn (Builder $query) => $query->where('something', '=', true)),
            ...
        ];
    }
}

In your template, add this above your table

<x-filament-panels::resources.tabs /> 

{{ $this->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 found

fervent drift
#

If it works, that would be great 🙂 I'll let you know. Thank you good man 🙂

fervent drift
#

The above error appears. I will be grateful for your help 🙂

coral garnet
#

What's your getTabs code?

fervent drift
#

public function getTabs(): array
{
return [
'all' => Tab::make(('All')),
'anotherTab' => Tab::make(
('Another tab'))
->modifyQueryUsing(fn (Builder $query) => $query->where('something', '=', true)),
];
}

coral garnet
# fervent drift

Also, is that the whole file? Put the <x-filament-panels::resources.tabs /> code inside the parent div

coral garnet
fervent drift
coral garnet
#

Is everything up to date? Filament 3, laravel etc?

fervent drift
#

yes

#

Updated today

coral garnet
#

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?

fervent drift
#

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.

coral garnet
fervent drift
#

🙂

coral garnet
#

This looks unrelated 🤔 Can you run regular cleanup step (clean cache/npm build etc/filament update etc)

fervent drift
coral garnet
#

can you remove the <x-filament-panels::page stuff too?

fervent drift
coral garnet
#

leave something simple like

<div>
    <div class="flex flex-col gap-y-6">
        <x-filament-panels::resources.tabs />
  
        {{ $this->table }}
    </div>
</div>
coral garnet
fervent drift
fervent drift
coral garnet
#

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

    @dump($this->getTabs())
    <x-filament-panels::resources.tabs />
fervent drift
coral garnet
#

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 so

fervent drift
coral garnet
#

Ok that's probably why nothing shows 🤔

#

Can you add this method just to see if it works

    public function getCachedTabs(): array
    {
        return $this->getTabs();
    }
fervent drift
#

❤️

coral garnet
#

This is weird. It should work without it. Maybe you have something that conflicts 🤔

fervent drift
#

It worked. Great thanks for your help. Should I somehow fix the code or leave this "workaround" (I guess)?

coral garnet
#

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

@if (count($tabs = $this->getCachedTabs()))

returns false and doesn't show anything

fervent drift
#

I'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 😃 )

coral garnet
#

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

fervent drift
#

@coral garnet 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 🙂