diff --git a/Controller/DynamicController.php b/Controller/DynamicController.php index 010df145..b5eed996 100644 --- a/Controller/DynamicController.php +++ b/Controller/DynamicController.php @@ -164,7 +164,7 @@ protected function getFilters(Request $request): array 'fromDate' => $request->get('fromDate'), 'toDate' => $request->get('toDate'), 'search' => $request->get('search'), - 'searchFields' => \array_filter(\explode(',', $request->get('searchFields', ''))), + 'searchFields' => \array_filter(\explode(',', $request->get('fields', ''))), ]; return \array_filter($filters); diff --git a/Repository/DynamicRepository.php b/Repository/DynamicRepository.php index 81d8588d..77e4ff17 100644 --- a/Repository/DynamicRepository.php +++ b/Repository/DynamicRepository.php @@ -129,14 +129,12 @@ protected function addSearchFilter(QueryBuilder $queryBuilder, ?string $search, // Search each term in each search field foreach ($terms as $counter => $term) { - $expressions = []; - - foreach ($searchFields as $searchField) { - $expressions[] = $queryBuilder->expr()->like( - 'dynamic.' . $searchField, + $expressions = [ + $queryBuilder->expr()->like( + 'dynamic.data', ':searchTerm' . $counter - ); - } + ), + ]; $queryBuilder->andWhere(\call_user_func_array([$queryBuilder->expr(), 'orX'], $expressions)); $queryBuilder->setParameter('searchTerm' . $counter, '%' . $term . '%');