N:m Pivot FilterPermit to filter a list using a Many-to-Many relation table. Instance a pivot filter
2. Then, drop a N:m table relation node into the filter. In the builder, from the Local layout (ex: Cities), - Open a the Pivot Table (ex : Visits)
- Find and drag the Foreign table node (ex: Travellers)
You can eventually open this Foreign Table node and choose the label field. (ex: Name)
By default (when you don't specify the Foreign Table label field), the label field will be the default field of the table (Yellow star)
Source codeIn ModelList :: prepareQuery(), the function :
$this->filterPivot('travellers');
type="relation" relation="travellers" labelKey="name"
You can customize the logic behaviors using the state vars. (For our example, 'travellers', is the name of the relation)
Remember that the states var must be initialized BEFORE getItems() of the model. // Match At least one value $this->setState('filter.travellers.logic', 'OR'); // Match All values $this->setState('filter.travellers.logic', 'AND'); // Exclude All values $this->setState('filter.travellers.logic', 'NOT'); |
|