F
Filament5mo ago
Gudao

Edit Page not showing Hidden Field

I am encountering this problem with a Conditional Select Field where if the role of the user is Vendor, another section appears but if it is defaulted as Vendor in Edit User, it is not visible and you have to reselect it to Vendor for it to reappear. How can I fix this? return $form ->schema([ 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(), ]), 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'), ]) ->hidden(fn (Get $get): bool => $get('roles') != 2) //2 is the id of Vendor role ]), Here is the code for context
1 Reply
Andrew Wallo
Andrew Wallo5mo ago
I am not sure if Filament sections support a dynamic hidden state.