Skip to content

Commit

Permalink
Revert global search GET to POST (CFM-323) (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen authored Oct 5, 2023
1 parent 74c452f commit 2c8a7d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/src/Controller/DashboardsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ public function search() {

// Gather our search string.
$q = '';
if(!empty($this->request->getQuery('q'))) {
if(!empty($this->request->getData('q'))) {
// A search was passed in from the form on the Global Search bar.
$q = trim($this->request->getQuery('q'));
$q = trim($this->request->getData('q'));
}

// Only process the request if we have a string of non-space characters
Expand Down Expand Up @@ -398,7 +398,7 @@ public function search() {

$this->Flash->information(__d('result',
'search.exact',
[filter_var($this->request->getQuery('q'), FILTER_SANITIZE_SPECIAL_CHARS),
[filter_var($this->request->getData('q'), FILTER_SANITIZE_SPECIAL_CHARS),
__d('controller', $matchClass, [1])]));

// Redirect to the matchClass controller
Expand Down
7 changes: 3 additions & 4 deletions app/templates/element/searchGlobal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

$options = [
'type' => 'get',
'type' => 'post',
'url' => [
'plugin' => null,
'controller' => 'dashboards',
Expand All @@ -52,16 +52,15 @@
['class' => 'visually-hidden']
);
$globalSearchInputClass = 'global-search-query';
if(!empty($this->request->getQuery('q'))) {
if(!empty($this->request->getData('q'))) {
$globalSearchInputClass .= ' has-value';
}
print $this->Form->input(
'q',
[
'id' => 'q',
'class' => $globalSearchInputClass,
'placeholder' => __d('field','search.placeholder'),
'value' => $this->request->getQuery('q')
'placeholder' => __d('field','search.placeholder')
]
);
print $this->Form->button(
Expand Down

0 comments on commit 2c8a7d2

Please sign in to comment.