diff --git a/src/Forms/CurrencyField_Disabled.php b/src/Forms/CurrencyField_Disabled.php
index 7e743755e..68145d41f 100644
--- a/src/Forms/CurrencyField_Disabled.php
+++ b/src/Forms/CurrencyField_Disabled.php
@@ -3,6 +3,7 @@
namespace SilverStripe\Forms;
use SilverStripe\Core\Convert;
+use SilverStripe\ORM\FieldType\DBCurrency;
/**
* Readonly version of a {@link CurrencyField}.
@@ -13,7 +14,7 @@ class CurrencyField_Disabled extends CurrencyField
protected $disabled = true;
/**
- * overloaded to display the correctly formated value for this datatype
+ * Overloaded to display the correctly formatted value for this data type
*
* @param array $properties
* @return string
@@ -22,7 +23,8 @@ class CurrencyField_Disabled extends CurrencyField
{
if ($this->value) {
$val = Convert::raw2xml($this->value);
- $val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.-]/', "", $val), 2);
+ $val = DBCurrency::config()->get('currency_symbol')
+ . number_format(preg_replace('/[^0-9.-]/', '', $val), 2);
$valforInput = Convert::raw2att($val);
} else {
$valforInput = '';
diff --git a/src/Forms/CurrencyField_Readonly.php b/src/Forms/CurrencyField_Readonly.php
index 775b9eb6b..292827600 100644
--- a/src/Forms/CurrencyField_Readonly.php
+++ b/src/Forms/CurrencyField_Readonly.php
@@ -3,6 +3,7 @@
namespace SilverStripe\Forms;
use SilverStripe\Core\Convert;
+use SilverStripe\ORM\FieldType\DBCurrency;
/**
* Readonly version of a {@link CurrencyField}.
@@ -11,19 +12,20 @@ class CurrencyField_Readonly extends ReadonlyField
{
/**
- * Overloaded to display the correctly formated value for this datatype
+ * Overloaded to display the correctly formatted value for this data type
*
* @param array $properties
* @return string
*/
public function Field($properties = array())
{
+ $currencySymbol = DBCurrency::config()->get('currency_symbol');
if ($this->value) {
$val = Convert::raw2xml($this->value);
- $val = _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.-]/', "", $val), 2);
+ $val = $currencySymbol . number_format(preg_replace('/[^0-9.-]/', '', $val), 2);
$valforInput = Convert::raw2att($val);
} else {
- $val = '' . _t('SilverStripe\\Forms\\CurrencyField.CURRENCYSYMBOL', '$') . '0.00';
+ $val = '' . $currencySymbol . '0.00';
$valforInput = '';
}
return "extraClass() . "\" id=\"" . $this->ID() . "\">$val"
diff --git a/tests/php/Forms/CurrencyField_DisabledTest.php b/tests/php/Forms/CurrencyField_DisabledTest.php
new file mode 100644
index 000000000..ed832521c
--- /dev/null
+++ b/tests/php/Forms/CurrencyField_DisabledTest.php
@@ -0,0 +1,34 @@
+Field();
+
+ $this->assertContains('assertContains('disabled', $result, 'The input should be disabled');
+ $this->assertContains('$5.00', $result, 'The value should be rendered');
+ }
+
+ /**
+ * @todo: Update the expectation when intl for currencies is implemented
+ */
+ public function testFieldWithCustomisedCurrencySymbol()
+ {
+ DBCurrency::config()->update('currency_symbol', '€');
+ $field = new CurrencyField_Disabled('Test', '', '€5.00');
+ $result = $field->Field();
+
+ $this->assertContains('assertContains('disabled', $result, 'The input should be disabled');
+ $this->assertContains('€5.00', $result, 'The value should be rendered');
+ }
+}
diff --git a/tests/php/Forms/CurrencyField_ReadonlyTest.php b/tests/php/Forms/CurrencyField_ReadonlyTest.php
new file mode 100644
index 000000000..289327cd1
--- /dev/null
+++ b/tests/php/Forms/CurrencyField_ReadonlyTest.php
@@ -0,0 +1,53 @@
+performReadonlyTransformation();
+ $this->assertInstanceOf(CurrencyField_Readonly::class, $result);
+ $this->assertNotSame($result, $field, 'Should return a clone of the field');
+ }
+
+ public function testFieldWithValue()
+ {
+ $field = new CurrencyField_Readonly('Test', '', '$5.00');
+ $result = $field->Field();
+
+ $this->assertContains('assertContains('readonly', $result, 'The input should be readonly');
+ $this->assertContains('$5.00', $result, 'The value should be rendered');
+ }
+
+ public function testFieldWithOutValue()
+ {
+ DBCurrency::config()->update('currency_symbol', 'AUD');
+ $field = new CurrencyField_Readonly('Test', '', null);
+ $result = $field->Field();
+
+ $this->assertContains('assertContains('readonly', $result, 'The input should be readonly');
+ $this->assertContains('AUD0.00', $result, 'The value should be rendered');
+ }
+
+ /**
+ * @todo: Update the expectation when intl for currencies is implemented
+ */
+ public function testFieldWithCustomisedCurrencySymbol()
+ {
+ DBCurrency::config()->update('currency_symbol', '€');
+ $field = new CurrencyField_Readonly('Test', '', '€5.00');
+ $result = $field->Field();
+
+ $this->assertContains('assertContains('readonly', $result, 'The input should be readonly');
+ $this->assertContains('€5.00', $result, 'The value should be rendered');
+ }
+}