diff --git a/src/Datagrid.php b/src/Datagrid.php index 7deaa83..0490329 100644 --- a/src/Datagrid.php +++ b/src/Datagrid.php @@ -429,10 +429,21 @@ protected function getData($key = null) $this->orderColumn = NULL; } + $validFilterData = []; + if ($this->filterFormFactory) { + $this['form']->isValid(); // triggers validation + foreach ($this['form']['filter']->getControls() as $name => $control) { + if ($control->getErrors() === []) { + $validFilterData[$name] = $control->getValue(); + } + } + $validFilterData = $this->filterFormFilter($validFilterData); + } + if (!$onlyRow && $this->paginator) { $itemsCount = call_user_func( $this->paginatorItemsCountCallback, - $this->filterDataSource, + $validFilterData, $this->orderColumn ? [$this->orderColumn, strtoupper($this->orderType)] : null ); @@ -444,7 +455,7 @@ protected function getData($key = null) $this->data = call_user_func( $this->dataSourceCallback, - $this->filterDataSource, + $validFilterData, $this->orderColumn ? [$this->orderColumn, strtoupper($this->orderType)] : null, $onlyRow ? null : $this->paginator );