From 2de66ff2cf2317681139737c94f84e6795ebbd85 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Tue, 8 Dec 2020 15:07:17 +0100 Subject: [PATCH] fix: [component:CRUD] Allow filtering by array of values --- src/Controller/Component/CRUDComponent.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 85053a6..8942160 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -354,10 +354,14 @@ class CRUDComponent extends Component if ($filter === 'quickFilter') { continue; } - if (strlen(trim($filterValue, '%')) === strlen($filterValue)) { - $query->where([$filter => $filterValue]); + if (is_array($filterValue)) { + $query->where([($filter . ' IN') => $filterValue]); } else { - $query->like([$filter => $filterValue]); + if (strlen(trim($filterValue, '%')) === strlen($filterValue)) { + $query->where([$filter => $filterValue]); + } else { + $query->like([$filter => $filterValue]); + } } } }