© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
codeartisan

Conditional Rendering in filament forms

I have a form and I want when a use selects sponsorChild I show the children dropdown , when i select Rescue Baby I show the baby dropdown
->schema([
                Forms\Components\Select::make('sponsor.sponor_id')
                    ->relationship('sponsor', 'first_name')
                    ->native(false)
                    ->label("Sponsor Name")
                    ->searchable()
                    ->preload(),
                Forms\Components\Select::make('type')
                    ->live()
                    ->options([
                        'RescueBaby' => 'Rescue Baby',
                        'SponsorChild' => 'Sponsor Child',
                    ])
                    ->searchable()
                    ->preload()
                    ->label("Type")
                    ->required(),
                Forms\Components\Select::make('child_id')
                    ->label('Children Name')
                    ->options(Children::all()->pluck('first_name', 'id'))
                    ->searchable()
                    ->visible(fn (Form $component) => $component->getState() === 'SponsorChild')
                    ->preload(),
                Forms\Components\Select::make('baby_id')
                    ->label('Babies Homes')
                    ->options(Children::all()->pluck('first_name', 'id'))
                    ->searchable()
                    ->visible(fn (Form $component) => $component->getState() === 'RescueBaby')
                    ->preload(),
            ]);
->schema([
                Forms\Components\Select::make('sponsor.sponor_id')
                    ->relationship('sponsor', 'first_name')
                    ->native(false)
                    ->label("Sponsor Name")
                    ->searchable()
                    ->preload(),
                Forms\Components\Select::make('type')
                    ->live()
                    ->options([
                        'RescueBaby' => 'Rescue Baby',
                        'SponsorChild' => 'Sponsor Child',
                    ])
                    ->searchable()
                    ->preload()
                    ->label("Type")
                    ->required(),
                Forms\Components\Select::make('child_id')
                    ->label('Children Name')
                    ->options(Children::all()->pluck('first_name', 'id'))
                    ->searchable()
                    ->visible(fn (Form $component) => $component->getState() === 'SponsorChild')
                    ->preload(),
                Forms\Components\Select::make('baby_id')
                    ->label('Babies Homes')
                    ->options(Children::all()->pluck('first_name', 'id'))
                    ->searchable()
                    ->visible(fn (Form $component) => $component->getState() === 'RescueBaby')
                    ->preload(),
            ]);
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Conditional createOptionForm in Filament
FilamentFFilament / ❓┊help
10mo ago
Filament Testing Forms in Modal
FilamentFFilament / ❓┊help
3y ago
Toggle sections in filament forms
FilamentFFilament / ❓┊help
3y ago
Filament forms createOptionForm
FilamentFFilament / ❓┊help
3y ago