diff --git a/Datagrid/Datagrid.php b/Datagrid/Datagrid.php index f26d1d8009..bbd6250e36 100644 --- a/Datagrid/Datagrid.php +++ b/Datagrid/Datagrid.php @@ -183,7 +183,7 @@ public function setValue($name, $operator, $value) public function hasActiveFilters() { foreach ($this->filters as $name => $filter) { - if ($this->hasActiveFilter($name)) { + if ($filter->isActive()) { return true; } } @@ -191,16 +191,6 @@ public function hasActiveFilters() return false; } - /** - * @param $name - * @return bool - */ - public function hasActiveFilter($name) - { - return isset($this->values[$name]) - && ! empty($this->values[$name]['value']); - } - /** * @return \Sonata\AdminBundle\Admin\FieldDescriptionCollection */ diff --git a/Datagrid/DatagridInterface.php b/Datagrid/DatagridInterface.php index 8dcd2b6a75..186a0868c8 100644 --- a/Datagrid/DatagridInterface.php +++ b/Datagrid/DatagridInterface.php @@ -102,11 +102,4 @@ function removeFilter($name); * @return boolean */ public function hasActiveFilters(); - - /** - * @abstract - * @param $name - * @return bool - */ - public function hasActiveFilter($name); } diff --git a/Filter/Filter.php b/Filter/Filter.php index 1c770c08ae..616e310a32 100644 --- a/Filter/Filter.php +++ b/Filter/Filter.php @@ -148,6 +148,15 @@ public function getValue() return $this->value; } + /** + * @return string + */ + public function isActive() + { + $values = $this->getValue(); + return ! empty($values['value']); + } + /** * @param $condition * @return void @@ -164,4 +173,4 @@ public function getCondition() { return $this->condition; } -} \ No newline at end of file +} diff --git a/Resources/views/CRUD/base_list.html.twig b/Resources/views/CRUD/base_list.html.twig index 3943d49e1f..deffbd32d8 100644 --- a/Resources/views/CRUD/base_list.html.twig +++ b/Resources/views/CRUD/base_list.html.twig @@ -166,7 +166,7 @@ file that was distributed with this source code.
{{ admin.trans(filter.label) }} | {{ form_widget(form.getChild(filter.name).getChild('type')) }} | {{ form_widget(form.getChild(filter.name).getChild('value')) }} |