mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Allow percentage fields to store 100%
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2@83164 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e798007f0a
commit
e33a314256
@ -44,4 +44,4 @@ class Decimal extends DBField {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -20,12 +20,21 @@ class Percentage extends Decimal {
|
||||
if( !$precision )
|
||||
$precision = 4;
|
||||
|
||||
parent::__construct($name, $precision, $precision);
|
||||
parent::__construct($name, $precision + 1, $precision);
|
||||
}
|
||||
|
||||
function Nice() {
|
||||
return number_format($this->value * 100, $this->decimalSize - 2) . '%';
|
||||
}
|
||||
|
||||
function saveInto($dataObject) {
|
||||
parent::saveInto($dataObject);
|
||||
|
||||
$fieldName = $this->name;
|
||||
if($fieldName && $dataObject->$fieldName > 1.0) {
|
||||
$dataObject->$fieldName = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user