Skip to content

Commit

Permalink
reset filter in case of $preselections are empt
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Kaltofen committed Jul 11, 2018
1 parent 3ec83aa commit 7851c5f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ContentElement/ContentListPreselect.php
Expand Up @@ -205,19 +205,20 @@ protected function compile()
*/
protected function preselect()
{
if (null === ($filterConfig = System::getContainer()->get('huh.filter.manager')->findById($this->filterConfig->getId())) || null === ($elements = $filterConfig->getElements())) {
return;
}

/** @var FilterPreselectModel $preselections */
$preselections = System::getContainer()->get('contao.framework')->createInstance(FilterPreselectModel::class);

if (null === ($preselections = $preselections->findPublishedByPidAndTableAndField($this->id, 'tl_content', 'filterPreselect'))) {
$filterConfig->resetData(); // reset previous filters
return;
}

$data = System::getContainer()->get('huh.filter.util.filter_preselect')->getPreselectData($this->filterConfig->getId(), $preselections->getModels());

if (null === ($filterConfig = System::getContainer()->get('huh.filter.manager')->findById($this->filterConfig->getId())) || null === ($elements = $filterConfig->getElements())) {
return;
}

$filterConfig->setData($data);
}
}

0 comments on commit 7851c5f

Please sign in to comment.