FilterEditor: fix buggy dropdown boxes
There were some issues with option names. Also cleaned up HTML a little bit and added autosubmission.
This commit is contained in:
parent
b40d0f6a1e
commit
1dcf44b9cd
|
@ -48,31 +48,22 @@ class FilterEditor extends AbstractWidget
|
||||||
} else {
|
} else {
|
||||||
$attributes = $view->propertiesToString($attributes);
|
$attributes = $view->propertiesToString($attributes);
|
||||||
}
|
}
|
||||||
$html = '<select name="' . $view->escape($name) . '"' . $attributes . '>';
|
$html = '<select name="' . $view->escape($name) . '"' . $attributes . ' class="autosubmit">' . "\n";
|
||||||
$beenActive = false;
|
|
||||||
sort($list);
|
asort($list);
|
||||||
foreach ($list as $k => $v) {
|
foreach ($list as $k => $v) {
|
||||||
$active = '';
|
$active = '';
|
||||||
if ($k === $selected) {
|
if ($k === $selected) {
|
||||||
$active = ' selected="selected"';
|
$active = ' selected="selected"';
|
||||||
$beenActive = true;
|
|
||||||
}
|
}
|
||||||
$v = str_replace('_', ' ', ucfirst($v));
|
|
||||||
$html .= sprintf(
|
$html .= sprintf(
|
||||||
'<option value="%s"%s>%s</option>',
|
' <option value="%s"%s>%s</option>' . "\n",
|
||||||
$view->escape($k),
|
$view->escape($k),
|
||||||
$active,
|
$active,
|
||||||
$view->escape($v)
|
$view->escape($v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (! $beenActive && $selected) {
|
$html .= '</select>' . "\n\n";
|
||||||
$html .= sprintf(
|
|
||||||
'<option value="%s" selected="selected">%s</option>',
|
|
||||||
$view->escape($selected),
|
|
||||||
$view->escape(str_replace('_', ' ', ucfirst(ltrim($selected, '_'))))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$html .= '</select>';
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +136,7 @@ class FilterEditor extends AbstractWidget
|
||||||
. '</li></ul>';
|
. '</li></ul>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$html .= $op . '<ul><li>' . implode('</li><li>', $parts) . '</li></ul>';
|
$html .= $op . "<ul>\n <li>\n" . implode("</li>\n <li>", $parts) . "</li>\n</ul>\n";
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
@ -205,6 +196,19 @@ class FilterEditor extends AbstractWidget
|
||||||
protected function selectColumn($filter)
|
protected function selectColumn($filter)
|
||||||
{
|
{
|
||||||
$name = 'column_' . $filter->getId();
|
$name = 'column_' . $filter->getId();
|
||||||
|
$cols = $this->arrayForSelect($this->query->getColumns());
|
||||||
|
$active = $filter->getColumn();
|
||||||
|
$seen = false;
|
||||||
|
foreach ($cols as $k => & $v) {
|
||||||
|
$v = str_replace('_', ' ', ucfirst($v));
|
||||||
|
if ($k === $active) {
|
||||||
|
$seen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$seen) {
|
||||||
|
$cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_')));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->query === null) {
|
if ($this->query === null) {
|
||||||
return sprintf(
|
return sprintf(
|
||||||
|
@ -215,8 +219,8 @@ class FilterEditor extends AbstractWidget
|
||||||
} else {
|
} else {
|
||||||
return $this->select(
|
return $this->select(
|
||||||
$name,
|
$name,
|
||||||
$this->arrayForSelect($this->query->getColumns()),
|
$cols,
|
||||||
$filter->getColumn()
|
$active
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue