F
Filament2mo ago
aldec

Conditional tab visibility triggers weird form glitch

Hello! I have a form, where the visibility of a tab is dependent on the selection from another tab. Every time the tab's visibility is true, the content from last tab in the form get's displayed under each tab as well (rather complicated to explain so I added some pictures). Here is the code from the form:
public static function getForm(): array
{
return [
Tabs::make('Tabs')
->columnSpanFull()
->tabs([
Tabs\Tab::make(label('process.tabs.basic'))
->schema([
Fieldset::make(label('process.fieldsets.basic'))
->schema([
Select::make('application_type')
->live()
->multiple()
->required()
->options(AufbruchSetting::getOptions("application_type"))
->label(label('process.fields.application_type')),
]),
]),
Tabs\Tab::make(label('process.tabs.excavation'))
->visible(function ($record, $get) {
if ($record) {
return $record->excavation !== null;
}

$applicationTypes = $get('application_type') ?? [];
return in_array('Aufbruchgenehmigung', $applicationTypes);
})
->schema([
Fieldset::make(label('process.fieldsets.excavation'))
->relationship('excavation')
->schema(Excavation::getForm())
]),
Tabs\Tab::make(label('process.tabs.warranties'))
->schema([
Repeater::make(label('process.fields.warranties'))
]),
->contained(false)
];
}
public static function getForm(): array
{
return [
Tabs::make('Tabs')
->columnSpanFull()
->tabs([
Tabs\Tab::make(label('process.tabs.basic'))
->schema([
Fieldset::make(label('process.fieldsets.basic'))
->schema([
Select::make('application_type')
->live()
->multiple()
->required()
->options(AufbruchSetting::getOptions("application_type"))
->label(label('process.fields.application_type')),
]),
]),
Tabs\Tab::make(label('process.tabs.excavation'))
->visible(function ($record, $get) {
if ($record) {
return $record->excavation !== null;
}

$applicationTypes = $get('application_type') ?? [];
return in_array('Aufbruchgenehmigung', $applicationTypes);
})
->schema([
Fieldset::make(label('process.fieldsets.excavation'))
->relationship('excavation')
->schema(Excavation::getForm())
]),
Tabs\Tab::make(label('process.tabs.warranties'))
->schema([
Repeater::make(label('process.fields.warranties'))
]),
->contained(false)
];
}
I cut most of the other tabs and fields. The last tab (process.tabs.warranties) gets displayed under each other tab if the tab process.tabs.excavation is visible. When I put a different tab as the last one, this one is displayed under each tab. So it's not about the content of the specific last tab but it's position of being the last one.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server