mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Returns chainability in setValue from parent
This commit is contained in:
parent
1c72d6946d
commit
9c91e9820e
@ -17,7 +17,6 @@ namespace SilverStripe\ORM\FieldType;
|
||||
*/
|
||||
class DBCurrency extends DBDecimal
|
||||
{
|
||||
|
||||
/**
|
||||
* @config
|
||||
* @var string
|
||||
@ -38,9 +37,9 @@ class DBCurrency extends DBDecimal
|
||||
$val = $this->config()->currency_symbol . number_format(abs($this->value), 2);
|
||||
if ($this->value < 0) {
|
||||
return "($val)";
|
||||
} else {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,9 +50,9 @@ class DBCurrency extends DBDecimal
|
||||
$val = $this->config()->currency_symbol . number_format(abs($this->value), 0);
|
||||
if ($this->value < 0) {
|
||||
return "($val)";
|
||||
} else {
|
||||
return $val;
|
||||
}
|
||||
return $val;
|
||||
|
||||
}
|
||||
|
||||
public function setValue($value, $record = null, $markChanged = true)
|
||||
@ -62,9 +61,11 @@ class DBCurrency extends DBDecimal
|
||||
if (is_numeric($value)) {
|
||||
$this->value = $value;
|
||||
} elseif (preg_match('/-?\$?[0-9,]+(.[0-9]+)?([Ee][0-9]+)?/', $value, $matches)) {
|
||||
$this->value = str_replace(array('$',',',$this->config()->currency_symbol), '', $matches[0]);
|
||||
} else {
|
||||
$this->value = 0;
|
||||
$this->value = str_replace(['$', ',', $this->config()->currency_symbol], '', $matches[0]);
|
||||
}
|
||||
|
||||
$this->value = 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user