Bugfix NumericField shows (none) for 0 on readonly

This commit is contained in:
muskie9 2014-11-02 20:55:23 -06:00
parent bd23ff0a3a
commit 082c49c1b5
2 changed files with 26 additions and 0 deletions

View File

@ -44,4 +44,27 @@ class NumericField extends TextField {
public function dataValue() {
return (is_numeric($this->value)) ? $this->value : 0;
}
/**
* Returns a readonly version of this field
*/
public function performReadonlyTransformation() {
$field = new NumericField_Readonly($this->name, $this->title, $this->value);
$field->setForm($this->form);
return $field;
}
}
class NumericField_Readonly extends ReadonlyField{
public function performReadonlyTransformation() {
return clone $this;
}
public function Value() {
return Convert::raw2xml($this->value ?
"$this->value" : "0");
}
}

View File

@ -33,5 +33,8 @@ class NumericFieldTest extends SapphireTest {
$field->setValue('12.00');
$this->assertFalse($field->validate($validator));
$field->setValue(0);
$this->assertRegExp("#<span[^>]+>\s*0\s*<\/span>#", "".$field->performReadonlyTransformation()->Field()."");
}
}