Format.currency ViewHelper <f:format.currency>

Formats a given float to a currency representation.

Examples

Defaults

<f:format.currency>123.456</f:format.currency>
Copied!

Output:

123,46
Copied!

All parameters

<f:format.currency decimalSeparator="." thousandsSeparator="," decimals="2"
    currencySign="$" prependCurrency="true" separateCurrency="false"
>
    54321
</f:format.currency>
Copied!

Output:

$54,321.00
Copied!

Inline notation

{someNumber -> f:format.currency(thousandsSeparator: ',', currencySign: 'EUR')}
Copied!

Output:

54,321,00 EUR
Copied!

Depending on the value of {someNumber}.

Use dash for decimals without value

<f:format.currency useDash="true">123.00</f:format.currency>
Copied!

Output:

123,-
Copied!

Source code

Go to the source code of this ViewHelper: Format\CurrencyViewHelper.php (GitHub).

Arguments

The following arguments are available for the format.currency ViewHelper:

currencySign
Type
string
Default
''
The currency sign, eg $ or €.
decimalSeparator
Type
string
Default
','
The separator for the decimal point.
decimals
Type
int
Default
2
Set decimals places.
prependCurrency
Type
bool
Default
false
Select if the currency sign should be prepended
separateCurrency
Type
bool
Default
true
Separate the currency sign from the number by a single space, defaults to true due to backwards compatibility
thousandsSeparator
Type
string
Default
'.'
The thousands separator.
useDash
Type
bool
Default
false
Use the dash instead of decimal 00