Custom Filter Classes
Custom filter classes implement Custom Filters.
TIP
Runing php craft contentoverview/create/filter will create a file as a starting point for you.
Inject your class via the createCustomFilter factory method:
php
$co->createCustomFilter(MyFilter::class);Methods
You can override the following methods:
getLabel
php
public function getLabel(): stringReturns the label used for the select box.
getOptions
php
public function getOptions(): array|CollectionReturns the options used for the select box.
modifyQuery
php
public function modifyQuery(Section $sectionConfig, array $filter, ElementQueryInterface $query)This is mandatory for custom filters.
See example.
