Skip to content

Commit

Permalink
fixed category filter
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Aug 24, 2018
1 parent cbc3122 commit 2f7f6bd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/QueryBuilder/FilterQueryBuilder.php
Expand Up @@ -243,7 +243,10 @@ protected function whereCategoryWidget(FilterConfigElementModel $element, string
$data = $config->getData();
$value = $data[$name];

if (null === $value) {
$value = array_filter(!is_array($value) ? explode(',', $value) : $value);

// skip if empty to avoid sql error
if (empty($value)) {
return $this;
}

Expand All @@ -254,9 +257,16 @@ protected function whereCategoryWidget(FilterConfigElementModel $element, string
$alias.parentTable='".$filter['dataContainer']."' AND
$alias.entity=".$filter['dataContainer'].'.id
');
$this->andWhere($this->expr()->in($alias.'.category', ":$alias"));

$this->setParameter(":$alias", $value, \PDO::PARAM_STR);
$this->andWhere($this->expr()->in(
$alias.'.category',
array_map(
function ($val) {
return '"'.addslashes(Controller::replaceInsertTags(trim($val), false)).'"';
},
$value
)
));

return $this;
}
Expand Down

0 comments on commit 2f7f6bd

Please sign in to comment.