ActiveTab not updating

I am currently using the Tab component in an Edit Page. I am trying to conditionally load a ViewField only once the tab is open because it requires calling an api to get the desired content. The View is not called when it is hidden which is exactly what I want. However when I access the getActiveTab() function of the tab it does not show the current active tab even though the Tab, Tabs and ViewField component all are live(). This is my testcase which I illustrated using the label of a TextInput:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Tabs::make('Label')
->live()
->tabs([
Forms\Components\Tabs\Tab::make('Test1')
->schema([
//Just to have a default tab
]),
Forms\Components\Tabs\Tab::make('Real Tab I want to lazyload')
->live()
->hidden(fn(Contact $contact) => $form->getOperation() !== 'edit')
->schema([
Forms\Components\TextInput::make("test")
->live()
->label(
fn(\Filament\Forms\Components\Component $component) =>
time() .' - ' . $component
->getContainer()->getParentComponent()
->getContainer()->getParentComponent()
->getActiveTab()
),
]),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Tabs::make('Label')
->live()
->tabs([
Forms\Components\Tabs\Tab::make('Test1')
->schema([
//Just to have a default tab
]),
Forms\Components\Tabs\Tab::make('Real Tab I want to lazyload')
->live()
->hidden(fn(Contact $contact) => $form->getOperation() !== 'edit')
->schema([
Forms\Components\TextInput::make("test")
->live()
->label(
fn(\Filament\Forms\Components\Component $component) =>
time() .' - ' . $component
->getContainer()->getParentComponent()
->getContainer()->getParentComponent()
->getActiveTab()
),
]),
]);
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server