FilamentF
Filament3y ago
Sesh

Select filter grouping options in relation filter

I am struggling to get a Select filter on a relation working with option groups described here: https://filamentphp.com/docs/3.x/forms/fields/select#grouping-options

This is my Select field in the table filters:

SelectFilter::make('trends')
     ->label(__('Trends'))
     ->searchable()
     ->options($formattedData)
     ->preload(),


The format of the options is right and they get displayed correctly with the groups, butwhen i select an entry, I get this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'trends' in 'where clause'
SELECT
  count(*) AS aggregate
FROM
  `news`
WHERE
  (`trends` = 1)


How can I configure the select so its checking the relation. When I use ->relation() it takes the options from the relation and not from the customized option array. Thanks.
Was this page helpful?