Pierre Causse
Pierre Causse

Reputation: 38

Where and How I can modify the money_pattern of a MoneyType under Symfony 6

I would like to understand where and how I can cleanly modify the money_pattern of a MoneyType under Symfony 6.

I tried in :

Impossible to apply the value : money_pattern => '{{ widget }} €'

Thanks in advance for your answers

Upvotes: 0

Views: 246

Answers (1)

Alister Bulman
Alister Bulman

Reputation: 35169

money_pattern is fetched within the MoneyType based on the currency (so, 'EUR'). However, it is also affected by the locale that is set.

In (my own) default 'en', it is set to € {{ widget }}, but after setting \Locale::setDefault('de_DE'); the placement becomes {{ widget }} €.

That pattern comes from the PHP Extension ext-intl (or the symfony/polyfill-intl-icu - but the polyfill only has support for the 'en' locale).

If the currency is set as false, then the widget does not have a sign around it, and can be overridden in the twig/form template widgets, potentially overriding the money_widget custom form template.

Upvotes: 1

Related Questions