Skip to content

Commit

Permalink
[4.4] Fix SQL field, get the filter value from the linked filter field (
Browse files Browse the repository at this point in the history
#43789)

* Fix SQL field, get the filter value from the linked filter field

* cs

* esc

---------
  • Loading branch information
Fedik authored Aug 5, 2024
1 parent 789ed19 commit c73f790
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libraries/src/Form/Field/SqlField.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,21 @@ protected function processQuery($conditions, $filters, $defaults)

// Process the filters
if (\is_array($filters)) {
$html_filters = Factory::getApplication()->getUserStateFromRequest($this->context . '.filter', 'filter', [], 'array');
// @TODO: Loading the filtering value from the request need to be deprecated.
$html_filters = $this->context ? Factory::getApplication()->getUserStateFromRequest($this->context . '.filter', 'filter', [], 'array') : false;
$form = $this->form;

foreach ($filters as $k => $value) {
if (!empty($html_filters[$value])) {
// Get the filter value from the linked filter field
$filterFieldValue = $form->getValue($value, $this->group);

if ($html_filters && !empty($html_filters[$value])) {
$escape = $db->quote($db->escape($html_filters[$value]), false);

$query->where("{$value} = {$escape}");
} elseif ($filterFieldValue !== null) {
$escape = $db->quote($db->escape($filterFieldValue), false);

$query->where("{$value} = {$escape}");
} elseif (!empty($defaults[$value])) {
$escape = $db->quote($db->escape($defaults[$value]), false);
Expand Down

0 comments on commit c73f790

Please sign in to comment.