This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
It seems that all my Backend list filters are working fine as expected, except one (the filter by place is not working as expected).
This is the main Model definition (along with their relationships):
class Event extends Model
{
public $table = 'acme_myproject_events';
...
public $belongsTo = [
'place' => [
'Acme\MyProject\Models\Place'
],
'theme' => [
'Acme\MyProject\Models\Theme',
]
];
public $belongsToMany = [
'publishers' => [
'Acme\MyProject\Models\Publisher',
'table' => 'acme_myproject_event_publisher',
]
];
}
in my config_filters.yaml I have set the following
scopes:
event_date:
label: Filter by date
type: daterange
conditions: event_date >= ':after' AND event_date <= ':before'
theme:
label: Filter by theme
modelClass: Acme\MyProject\Models\Theme
conditions: theme_id in (:filtered)
nameFrom: name
place:
label: Filter by place
modelClass: Acme\MyProject\Models\Place
conditions: place_id in (:filtered)
nameFrom: name
publishers:
label: Filter by publishers
modelClass: Acme\MyProject\Models\Publisher
conditions: id in (select event_id from acme_myproject_event_publisher where publisher_id in (:filtered))
nameFrom: name
featured:
label: Is Featured
type: checkbox
conditions: featured = '1'
If I select multiple values for all these filters, the result query produced is like the following one:
SELECT `acme_myproject_events`.*,
(SELECT name FROM `acme_myproject_places` WHERE `acme_myproject_events`.`place_id` = `acme_myproject_places`.`id`) AS `place`,
(SELECT name FROM `acme_myproject_themes` WHERE `acme_myproject_events`.`theme_id` = `acme_myproject_themes`.`id`) AS `theme`
FROM `acme_myproject_events`
WHERE event_date >= '2016-10-04 22:00:00' AND event_date <= '2016-12-25 22:59:59'
AND theme_id IN ('4','48','50')
AND id IN (SELECT event_id FROM acme_myproject_event_publisher WHERE publisher_id IN ('1','3','5','7','4'))
AND featured = '1'
ORDER BY `place` DESC LIMIT 20 OFFSET 0
Which should be the result of selecting these filters
As you can notice above, the filters are all applied in the WHERE statement, except the place filter. I would expect to see also AND place_id IN ('1','4') in the Where statement, but this filter is not applied at all.
UPDATE After diggin further in the forum, I've found out that this problem could be related to this other issue: http://octobercms.com/forum/post/backend-filter-list-does-not-work-when-the-model-records-is-more-than-500 Infact, my places filter contains more than 500 records.
Last updated
1-1 of 1