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:
Eric Lippmann 2014-11-18 10:29:28 +01:00
parent 5ad1c0c928
commit e3629a7f41

View File

@ -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);
}
}