Skip to content

Commit

Permalink
fix: pass only valid filter inputs to data source callback [Closes ne…
Browse files Browse the repository at this point in the history
  • Loading branch information
Miloslav Hůla committed May 25, 2018
1 parent f806dd8 commit d4ea1f4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,21 @@ protected function getData($key = null)
$this->orderColumn = NULL;
}

$validFilterData = [];
if ($this->filterFormFactory) {
$this['form']->isValid(); // triggers validation
foreach ($this['form']['filters']->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
);

Expand All @@ -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
);
Expand Down

0 comments on commit d4ea1f4

Please sign in to comment.