When storing a currency value as integer (i.e. Cent), is there a way to display it in list view as Euro/Dollar?
Example: € 900 are stored in the database as 90000. EasyAdmin displays this as 90,000. What I'd like to have is 900 (or 900,00 or 900.00).
In EasyAdmin's form view, you can configure this via:
form:
fields:
- { property: 'centAmount', type: 'money', type_options: { divisor: 100, currency: 'EUR' } }
MoneyTypeis not supported in list view, see https://github.com/EasyCorp/EasyAdminBundle/issues/1995Here's the workaround outlined at https://github.com/EasyCorp/EasyAdminBundle/issues/1995#issuecomment-356717049 :
Create a file
/templates/easy_admin/money.html.twigwith:See
/vendor/easycorp/easyadmin-bundle/src/Resources/views/default/field_integer.html.twigfor the template that EasyAdmin uses by default.Activate your new template in
easy_admin.yaml:Result:
900,00 €Reference: https://symfony.com/doc/current/bundles/EasyAdminBundle/book/list-search-show-configuration.html#rendering-entity-properties-with-custom-templates