2016-08-19 10:51:35 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
|
|
|
use SilverStripe\Core\Convert;
|
2018-10-20 17:41:41 +02:00
|
|
|
use SilverStripe\ORM\FieldType\DBCurrency;
|
2016-08-19 10:51:35 +12:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Readonly version of a {@link CurrencyField}.
|
|
|
|
*/
|
|
|
|
class CurrencyField_Disabled extends CurrencyField
|
|
|
|
{
|
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
protected $disabled = true;
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
/**
|
2018-10-20 17:41:41 +02:00
|
|
|
* Overloaded to display the correctly formatted value for this data type
|
2016-11-29 12:31:16 +13:00
|
|
|
*
|
|
|
|
* @param array $properties
|
|
|
|
* @return string
|
|
|
|
*/
|
2020-04-20 18:58:09 +01:00
|
|
|
public function Field($properties = [])
|
2016-11-29 12:31:16 +13:00
|
|
|
{
|
|
|
|
if ($this->value) {
|
|
|
|
$val = Convert::raw2xml($this->value);
|
2018-10-20 17:41:41 +02:00
|
|
|
$val = DBCurrency::config()->get('currency_symbol')
|
|
|
|
. number_format(preg_replace('/[^0-9.-]/', '', $val), 2);
|
2016-11-29 12:31:16 +13:00
|
|
|
$valforInput = Convert::raw2att($val);
|
|
|
|
} else {
|
|
|
|
$valforInput = '';
|
|
|
|
}
|
|
|
|
return "<input class=\"text\" type=\"text\" disabled=\"disabled\""
|
|
|
|
. " name=\"" . $this->name . "\" value=\"" . $valforInput . "\" />";
|
|
|
|
}
|
2016-08-19 10:51:35 +12:00
|
|
|
}
|