Numeric input: validate inclusive ranges
This commit is contained in:
parent
a187966277
commit
5cf51a70c8
|
@ -46,11 +46,12 @@ class Number extends FormElement
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if ($this->min !== null) {
|
if ($this->min !== null || $this->max !== null) {
|
||||||
$this->addValidator('GreaterThan', true, array('min' => $this->min));
|
$this->addValidator('Between', true, array(
|
||||||
}
|
'min' => $this->min === null ? -INF : $this->min,
|
||||||
if ($this->max !== null) {
|
'max' => $this->max === null ? INF : $this->max,
|
||||||
$this->addValidator('LessThan', true, array('max' => $this->max));
|
'inclusive' => true
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ class Number extends FormElement
|
||||||
*/
|
*/
|
||||||
public function setMax($max)
|
public function setMax($max)
|
||||||
{
|
{
|
||||||
$this->max = (int) $max;
|
$this->max = (float) $max;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue