BUGFIX Money->setValue() was not working when loading $value and $record parameters, and only $record had a

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77790 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-05-26 01:08:27 +00:00
parent d8b46e5501
commit 2a58703ecf

View File

@ -101,7 +101,8 @@ class Money extends DBField implements CompositeDBField {
}
function setValue($value,$record=null) {
if ($value instanceof Money) {
// @todo Allow resetting value to NULL through Money $value field
if ($value instanceof Money && $value->hasValue()) {
$this->setCurrency($value->getCurrency());
$this->setAmount($value->getAmount());
} else if($record && isset($record[$this->name . 'Currency']) && isset($record[$this->name . 'Amount'])) {
@ -268,6 +269,7 @@ class Money extends DBField implements CompositeDBField {
public function scaffoldFormField($title = null) {
$field = new MoneyField($this->name);
$field->setAllowedCurrencies($this->getAllowedCurrencies());
$field->setLocale($this->getLocale());
return $field;
}