Fix: negative values in read only currency field

Don’t strip out ‘-‘ character as this makes negative values appear to be positive (Fixes #8126)
This commit is contained in:
Jonathon Menz 2018-06-01 12:52:22 -07:00
parent 624a5326a7
commit 5a5ba1e5c0
2 changed files with 2 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class CurrencyField_Disabled extends CurrencyField
{ {
if ($this->value) { if ($this->value) {
$val = Convert::raw2xml($this->value); $val = Convert::raw2xml($this->value);
$val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/', "", $val), 2); $val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.-]/', "", $val), 2);
$valforInput = Convert::raw2att($val); $valforInput = Convert::raw2att($val);
} else { } else {
$valforInput = ''; $valforInput = '';

View File

@ -20,7 +20,7 @@ class CurrencyField_Readonly extends ReadonlyField
{ {
if ($this->value) { if ($this->value) {
$val = Convert::raw2xml($this->value); $val = Convert::raw2xml($this->value);
$val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/', "", $val), 2); $val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.-]/', "", $val), 2);
$valforInput = Convert::raw2att($val); $valforInput = Convert::raw2att($val);
} else { } else {
$val = '<i>' . _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . '0.00</i>'; $val = '<i>' . _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . '0.00</i>';