F
Filament5mo ago
morty

Typed property Filament\Tables\Filters\BaseFilter::$table must not be accessed before initialization

I have a ListRecords page with a table and 3 stat widgets. The widgets are setup to interact with the filtered table via the ExposesTableToWidgets and InteractsWithPageTable traits . The table has 9 different filters. 8 out of these 9 filters work great and filter the table and the widgets react to the filtered table. However, one of these filters, the only one that is a relationship to the data causes an exception to be thrown. I'm not sure how to even begin troubleshooting this but this is the filter causing an issue:
Tables\Filters\SelectFilter::make('account')
->label('Account')
->placeholder('All')
->relationship('account', 'name')
->searchable(),
Tables\Filters\SelectFilter::make('account')
->label('Account')
->placeholder('All')
->relationship('account', 'name')
->searchable(),
If I turn off the widget ExposesTableToWidgets and InteractsWithPageTable traits, the filter works to filter the table so it's not an issue with the filter. I believe there is an issue with possibly using a relationship filter and those traits. Anyone here successful in achieving this?
No description
Solution:
I managed to solve this. I'm using kenneth-sese-advanced-tables plugin and it turns out I had to use the exact column name as the filter name. Therefore adding account.name to the make method resolved my issue. ```php Tables\Filters\SelectFilter::make('account.name') ->label('Account')...
Jump to solution
1 Reply
Solution
morty
morty5mo ago
I managed to solve this. I'm using kenneth-sese-advanced-tables plugin and it turns out I had to use the exact column name as the filter name. Therefore adding account.name to the make method resolved my issue.
Tables\Filters\SelectFilter::make('account.name')
->label('Account')
->placeholder('All')
->relationship('account', 'name')
->searchable(),
Tables\Filters\SelectFilter::make('account.name')
->label('Account')
->placeholder('All')
->relationship('account', 'name')
->searchable(),
Want results from more Discord servers?
Add your server