mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
Number element: Use is_numeric in favor of Zend's float validator
The float validator uses Zend_Locale which we have stripped in our vendor library thus leading to erroneous validation. Further we'll use php-intl instead of Zend_Locale one day :) fixes #7692
This commit is contained in:
parent
5ad1c0c928
commit
e3629a7f41
@ -47,7 +47,6 @@ class Number extends FormElement
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addValidator('Float', true); // true for breaking the validator chain on failure
|
||||
if ($this->min !== null) {
|
||||
$this->addValidator('GreaterThan', true, array('min' => $this->min));
|
||||
}
|
||||
@ -127,4 +126,19 @@ class Number extends FormElement
|
||||
{
|
||||
return $this->step;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPDoc)
|
||||
* @see \Zend_Form_Element::isValid() For the method documentation.
|
||||
*/
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
$this->setValue($value);
|
||||
$value = $this->getValue();
|
||||
if (! is_numeric($value)) {
|
||||
$this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value));
|
||||
return false;
|
||||
}
|
||||
return parent::isValid($value, $context);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user