mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
624a5326a7
commit
5a5ba1e5c0
@ -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 = '';
|
||||||
|
@ -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>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user