To achieve the functionality where you want to use a default filter clause and remove the operator selection in Filament using the Webbingbrasil\FilamentAdvancedFilter, you can customize the TextFilter to not display the clause selection dropdown. This can be done by overriding the enableClauseLabel method to not render the clause selection UI.
Here's how you can modify your TextFilter setup:
use Webbingbrasil\FilamentAdvancedFilter\Filters\TextFilter;
use Filament\Forms\Components\Group;
TextFilter::make('title')
->default(TextFilter::CLAUSE_CONTAINS)
->wrapperUsing(fn () => Group::make())
->enableClauseLabel(false), // Disable the clause label dropdown
In this code:
-
TextFilter::make('title')creates a new text filter for the 'title' field. -
->default(TextFilter::CLAUSE_CONTAINS)sets the default clause to "contains". -
->wrapperUsing(fn () => Group::make())wraps the filter input in a group component. -
->enableClauseLabel(false)disables the clause label dropdown, effectively hiding the operator selection and using the default clause specified.
This setup ensures that the text filter for the 'title' field will always use the "contains" clause, and the user will not be able to change this from the UI.