Pre-select range "1 hour" by default

refs #78
This commit is contained in:
Alexander A. Klimov 2017-11-07 14:54:57 +01:00
parent 2c6cd09fa2
commit a9dae9e1b9

View file

@ -146,6 +146,10 @@ class CommonForm extends Form
*/
protected function urlToForm()
{
if ($this->preSelectDefault()) {
return;
}
$params = $this->getRedirectUrl()->getParams();
$seconds = $this->getRelativeSeconds($params);
@ -187,4 +191,23 @@ class CommonForm extends Form
}
}
}
/**
* If no range is specified, pre-select "1 hour"
*
* @return bool Whether no range is specified
*/
protected function preSelectDefault()
{
$params = $this->getRedirectUrl()->getParams();
foreach (static::getAllRangeParameters() as $parameter) {
if ($params->has($parameter)) {
return false;
}
}
$this->getElement('hours')->setValue('1');
return true;
}
}