diff --git a/src/ColumnType/CurrencyColumn.php b/src/ColumnType/CurrencyColumn.php index d592ee1..580c04c 100644 --- a/src/ColumnType/CurrencyColumn.php +++ b/src/ColumnType/CurrencyColumn.php @@ -17,6 +17,9 @@ public function configureOptions(OptionsResolver $resolver): void 'currency' => 'EUR', 'currency_path' => null, 'divider' => 0, + 'formatOptions' => [ + 'fraction_digit' => 2, + ], ]); $resolver->setAllowedTypes('currency', ['string', 'null']); diff --git a/src/Resources/views/column_types/currency.html.twig b/src/Resources/views/column_types/currency.html.twig index 708a8ea..65490bd 100644 --- a/src/Resources/views/column_types/currency.html.twig +++ b/src/Resources/views/column_types/currency.html.twig @@ -4,8 +4,14 @@ {% block column_content %} {% set amount = value %} + {% set currency = column.type.currency(data, column.options) %} + {% if amount is not null or column.options.nullAsZero %} - {{ amount|format_currency(column.type.currency(data, column.options), column.options.formatOptions) }} + {% if currency %} + {{ amount|format_currency(currency, column.options.formatOptions) }} + {% else %} + {{ amount|format_number(column.options.formatOptions) }} + {% endif %} {% if it_loop is defined and not it_loop.last %} {{ type.options.implode_separator }} {% endif %}