Skip to content

Commit

Permalink
Check if current min/max fields set
Browse files Browse the repository at this point in the history
  • Loading branch information
ychanan committed Apr 6, 2021
1 parent 77db6e0 commit f2d252d
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ public function prepareValuesForRendering(FilterConditionInterface $condition, F
$minValue = count($rawValues) > 0 ? $rawValues[0]['value'] : 0;
$maxValue = count($rawValues) > 0 ? $rawValues[count($rawValues) - 1]['value'] : 0;

$currentValueMin = $minValue;
if (isset($currentFilter["$field-min"]) && ('' !== (string)$currentFilter["$field-min"]) ) {
$currentValueMin = $currentFilter["$field-min"];
}

$currentValueMax = $maxValue;
if (isset($currentFilter["$field-max"]) && ('' !== (string)$currentFilter["$field-max"]) ) {
$currentValueMax = $currentFilter["$field-max"];
}

return [
'type' => 'range',
'label' => $condition->getLabel(),
'minValue' => $minValue,
'maxValue' => $maxValue,
'currentValueMin' => ('' !== (string)$currentFilter[$field . '-min']) ? $currentFilter[$field . '-min'] : $minValue,
'currentValueMax' => ('' !== (string)$currentFilter[$field . '-max']) ? $currentFilter[$field . '-max'] : $maxValue,
'currentValueMin' => $currentValueMin,
'currentValueMax' => $currentValueMax,
'values' => array_values($rawValues),
'fieldName' => $field,
'stepCount' => $condition->getConfiguration()['stepCount'],
Expand Down

0 comments on commit f2d252d

Please sign in to comment.