Merge pull request #8127 from jonom/4.0-read-only-currency

Fix: negative values in read only currency field
This commit is contained in:
Daniel Hensby 2018-06-04 11:52:01 +01:00 committed by GitHub
commit 1658fe7617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>';