Skip to content

Revert global search GET to POST (CFM-323) #128

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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