Displaying a money amount with Twig
Published on 2023-02-25 • Modified on 2023-02-25
This snippet shows how to display a money amount with Twig. There's a filter for that, and it handles the current locale. The following example uses EUR as a raw value, but when using data coming from the database, a good practice is to store both the currency and the amount (You have the currency type for your forms). Another good practice is to store the amount multiplicated by 100 so you don't have decimal problems; you can store the value in an integer field. You have the money type for that. Note that you must install the twig/intl-extra package to use this filter.