FilterEditor: clean up selectColumn

This commit is contained in:
Thomas Gelf 2014-11-15 23:42:15 +01:00
parent e6ded2eb3c
commit 1d4ea88251
1 changed files with 13 additions and 15 deletions

View File

@ -355,9 +355,19 @@ class FilterEditor extends AbstractWidget
array('style' => 'width: 4em') array('style' => 'width: 4em')
); );
} }
protected function selectColumn($filter)
protected function selectColumn(Filter $filter = null)
{ {
$name = 'column_' . $filter->getId(); $active = $filter === null ? null : $filter->getColumn();
if ($this->query === null) {
return sprintf(
'<input type="text" name="%s" value="%s" />',
$this->elementId('column', $filter),
$this->view()->escape($active) // Escape attribute?
);
}
$cols = $this->arrayForSelect($this->query->getColumns()); $cols = $this->arrayForSelect($this->query->getColumns());
$active = $filter->getColumn(); $active = $filter->getColumn();
$seen = false; $seen = false;
@ -372,19 +382,7 @@ class FilterEditor extends AbstractWidget
$cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_'))); $cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_')));
} }
if ($this->query === null) { return $this->select($this->elementId('column', $filter), $cols, $active);
return sprintf(
'<input type="text" name="%s" value="%s" />',
$name,
$filter->getColumn()
);
} else {
return $this->select(
$name,
$cols,
$active
);
}
} }
public function renderSearch() public function renderSearch()