MINOR If CurrencyField->setValue() passed a null or empty value, default to 0.00 so number_format() has no issues converting the number

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97566 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-01-26 03:45:10 +00:00 committed by Sam Minnee
parent 173473b707
commit a6f9a2539b

View File

@ -12,7 +12,8 @@ class CurrencyField extends TextField {
* allows the value to be set ( not including $ signs and number format...)
*/
function setValue($val) {
$this->value = '$' . number_format(ereg_replace('[^0-9.]',"",$val), 2);
$value = ($val) ? $val : 0.00;
$this->value = '$' . number_format(ereg_replace('[^0-9.]', '', $value), 2);
}
/**
* Overwrite the datavalue before saving to the db ;-)