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()
|
||||
{
|
||||
if ($this->min !== null) {
|
||||
$this->addValidator('GreaterThan', true, array('min' => $this->min));
|
||||
}
|
||||
if ($this->max !== null) {
|
||||
$this->addValidator('LessThan', true, array('max' => $this->max));
|
||||
if ($this->min !== null || $this->max !== null) {
|
||||
$this->addValidator('Between', true, array(
|
||||
'min' => $this->min === null ? -INF : $this->min,
|
||||
'max' => $this->max === null ? INF : $this->max,
|
||||
'inclusive' => true
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ class Number extends FormElement
|
|||
*/
|
||||
public function setMax($max)
|
||||
{
|
||||
$this->max = (int) $max;
|
||||
$this->max = (float) $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue