diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index b031ebe..23c1b50 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -341,6 +341,7 @@ class CRUDComponent extends Component { $queryConditions = []; if (!empty($params['quickFilter']) && !empty($quickFilterFields)) { + $this->Controller->set('quickFilterValue', $params['quickFilter']); foreach ($quickFilterFields as $filterField) { $likeCondition = false; if (is_array($filterField)) { @@ -352,6 +353,8 @@ class CRUDComponent extends Component } } $query->where(['OR' => $queryConditions]); + } else { + $this->Controller->set('quickFilterValue', ''); } return $query; } diff --git a/templates/Individuals/index.php b/templates/Individuals/index.php index 91520e1..0b92b4e 100644 --- a/templates/Individuals/index.php +++ b/templates/Individuals/index.php @@ -23,6 +23,7 @@ echo $this->element('genericElements/IndexTable/index_table', [ 'button' => __('Filter'), 'placeholder' => __('Enter value to search'), 'data' => '', + 'value' => $quickFilterValue, 'searchKey' => 'value' ] ] diff --git a/templates/element/genericElements/ListTopBar/group_search.php b/templates/element/genericElements/ListTopBar/group_search.php index 9b0b6f9..6387bef 100644 --- a/templates/element/genericElements/ListTopBar/group_search.php +++ b/templates/element/genericElements/ListTopBar/group_search.php @@ -57,7 +57,7 @@ var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-').val()); executePagination(randomValue, url); }); - $('#quickFilterField').on('keypress', function (e) { + $('#quickFilterField-' + randomValue).on('keypress', function (e) { if(e.which === 13) { var url = '/' + controller + '/' + action + additionalUrlParams + '?quickFilter=' + encodeURIComponent($('#quickFilterField-').val()); executePagination(randomValue, url);