From 9a1b38ff5abaa4e639e52fa70d75e6cf733da489 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Wed, 10 Mar 2021 09:36:45 +0100 Subject: [PATCH] chg: [CRUD] Passes active filters to the view --- src/Controller/Component/CRUDComponent.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 474313d..ef49ae9 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -396,17 +396,19 @@ class CRUDComponent extends Component } } + $activeFilters = []; if (!empty($customFilteringFunction['filterConditionFunction'])) { $query = $customFilteringFunction['filterConditionFunction']($query); + $activeFilters['filteringLabel'] = $filteringLabel; } else { if (!empty($chosenFilter)) { $params = $this->massageFilters($chosenFilter['filterCondition']); } else { $params = $this->massageFilters($params); } - $conditions = array(); if (!empty($params['simpleFilters'])) { foreach ($params['simpleFilters'] as $filter => $filterValue) { + $activeFilters[$filter] = $filterValue; if ($filter === 'quickFilter') { continue; } @@ -419,12 +421,13 @@ class CRUDComponent extends Component } if (!empty($params['relatedFilters'])) { foreach ($params['relatedFilters'] as $filter => $filterValue) { + $activeFilters[$filter] = $filterValue; $filterParts = explode('.', $filter); $query = $this->setNestedRelatedCondition($query, $filterParts, $filterValue); } } } - + $this->Controller->set('activeFilters', $activeFilters); return $query; }