lib: Fix Number::isValid()

- Calls $this->translate()
- Always performs is_numeric check, even if the element is not required
This commit is contained in:
Eric Lippmann 2015-09-07 16:57:09 +02:00
parent 947d5c6190
commit e8c21868ff
1 changed files with 2 additions and 2 deletions

View File

@ -134,8 +134,8 @@ class Number extends FormElement
{
$this->setValue($value);
$value = $this->getValue();
if (! is_numeric($value)) {
$this->addError(sprintf($this->translate('\'%s\' is not a valid number'), $value));
if ($this->isRequired() && ! is_numeric($value)) {
$this->addError(sprintf(t('\'%s\' is not a valid number'), $value));
return false;
}
return parent::isValid($value, $context);