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: CurrencyViewHelper.php (GitHub).

Arguments

The following arguments are available for <f:format.currency>:

Name display Type Default
string
string ','
string '.'
boolean
boolean true
mixed 2
boolean
currencySign
Type
string

The currency sign, eg $ or .

decimalSeparator
Type
string
Default
','

The separator for the decimal point.

thousandsSeparator
Type
string
Default
'.'

The thousands separator.

prependCurrency
Type
boolean

Select if the currency sign should be prepended

separateCurrency
Type
boolean
Default
true

Separate the currency sign from the number by a single space, defaults to true due to backwards compatibility

decimals
Type
mixed
Default
2

Set decimals places.

useDash
Type
boolean

Use the dash instead of decimal 00