Typed property Filament\Forms\Components\Component::$container must not be accessed

Hi, i'm trying to hide a column with a Closure filter to hide it when it is null. Code is the following
Tables\Columns\TextColumn::make('fax')
->searchable()
->hidden(fn(\Filament\Forms\Get $get) => $get("fax") === null),
Tables\Columns\TextColumn::make('fax')
->searchable()
->hidden(fn(\Filament\Forms\Get $get) => $get("fax") === null),
6 Replies
Patrick Boivin
Patrick Boivin16mo ago
Hi @giuszeppe, $get() is meant to be used in the context of a form. You can do the same in a table with:
->method(fn ($record) => $record->property === null)
->method(fn ($record) => $record->property === null)
But in this case I'm not sure it makes sense to hide columns based on the value, because you'll end up with uneven columns in your table. Are you trying to show an empty value instead?
giuszeppe
giuszeppeOP16mo ago
What if I wanted to reduce code duplication? I have many optional fields that I need to hide when null
Patrick Boivin
Patrick Boivin16mo ago
I'm not sure what you mean, your example is showing a table column
awcodes
awcodes16mo ago
Columns cannot be hidden like this on a per record basis. Html tables don’t support it. You can make a entire column toggleable which will sow or hide the column based on the users interaction.
giuszeppe
giuszeppeOP16mo ago
I was just wondering if it is possible to have something like ->hidden(hideIfNull) instead of rewriting every time the same logic.
awcodes
awcodes16mo ago
You could create a global helper function and pass in the state. This is still just laravel and php.
Want results from more Discord servers?
Add your server