© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Renzo

Hiding a section based on Select field value

I have created a function where the 2nd section is hidden unless the Role selected from the 1st section is 'Vendor' which has an ID of '2'. It works fine, but when I edit a users with an existing 'Vendor' role. the 2nd section doesn't show up. I'd have to select a different role and select Vendor again for it to show up.

Group::make()
                    ->schema([
                        Section::make()
                            ->schema([
                                TextInput::make('name')->label('Full Name'),
                                TextInput::make('email')->label('Email'),
                                TextInput::make('password')->label('Password')
                                    ->password()
                                    ->dehydrateStateUsing(fn (string $state): string => Hash::make($state))
                                    ->dehydrated(fn (?string $state): bool => filled($state)),
                                Select::make('roles')
                                    ->native(false)
                                    ->relationship('roles', 'name')
                                    ->live()
                                    ->searchDebounce(500)
                            ]),
                        Section::make()
                            ->schema([
                                TextInput::make('user_rate')->label('Rate')
                                ->numeric(),
                                TextInput::make('user_distance_rate')->label('Rate Per Distance')
                                ->numeric(),
                                Toggle::make('user_preferred')->label('Preferred'),
                            ])
                            ->visible(fn (Get $get): bool => $get('roles') == 2)
                    ]),
Group::make()
                    ->schema([
                        Section::make()
                            ->schema([
                                TextInput::make('name')->label('Full Name'),
                                TextInput::make('email')->label('Email'),
                                TextInput::make('password')->label('Password')
                                    ->password()
                                    ->dehydrateStateUsing(fn (string $state): string => Hash::make($state))
                                    ->dehydrated(fn (?string $state): bool => filled($state)),
                                Select::make('roles')
                                    ->native(false)
                                    ->relationship('roles', 'name')
                                    ->live()
                                    ->searchDebounce(500)
                            ]),
                        Section::make()
                            ->schema([
                                TextInput::make('user_rate')->label('Rate')
                                ->numeric(),
                                TextInput::make('user_distance_rate')->label('Rate Per Distance')
                                ->numeric(),
                                Toggle::make('user_preferred')->label('Preferred'),
                            ])
                            ->visible(fn (Get $get): bool => $get('roles') == 2)
                    ]),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Update a field based on select value
FilamentFFilament / ❓┊help
2y ago
Conditionally display a section, based on another field's value
FilamentFFilament / ❓┊help
2y ago
Select Option Disabled Based on Another Field's Value
FilamentFFilament / ❓┊help
12mo ago