FilamentF
Filament3y ago
Abi

`visible()` method doesn't work right with === check.

Here is the code snippet I have

 Select::make('table_style')
       ->options([
            0 => 'Default',
            1 => 'Style 1',
            2 => 'Style 2',
        ])->reactive()->required(),

Section::make('Default Settings')
        ->schema([
            Toggle::make('show_features')
                ->inline(false),
        ])->visible(fn(\Closure $get) => $get('table_style') == 0),

Section::make('Style 2 Settings')
        ->schema([
            Toggle::make('show_features')
                ->inline(false),
        ])->visible(fn(\Closure $get) => $get('table_style') === 1),

Section::make('Style 3 Settings')
        ->schema([
            Toggle::make('show_features')
                ->inline(false),
        ])->visible(fn(\Closure $get) => $get('table_style') === 2),


If I use === to check the visible condition, it doesn't work. But the same works with ==. Am i missing something? The key's on the Select fields are integer and I am checking against an integer.
Was this page helpful?