0

My application stores the prices of the orders like this:

id|price_total|currency|
--|-----------|--------|
 1|     127.65|EUR     |
 2|     197.65|USD     |
 3|     294.95|EUR     |

I need to display this within EasyAdmin 3:

# BuyOrderCrudController.php
public function configureFields(string $pageName): iterable
{

...
    yield CurrencyField::new("currency");
    yield MoneyField::new('price_total')
                ->setCurrency('EUR');
...
}

I need to fix the hardcoded EUR in ->setCurrency('EUR') by getting the EUR or USD value from the currency field.

I cannot figure out what syntax or function to use.

1 Answers1

0

i never had such a use case but one idea is to use easyadmin events, AfterCrudActionEvent or AfterEntityBuiltEvent, events dispatch an entityDto object wich has every thing you need (access to the entity and to the fields), you can get your field and your property and set your field their.

yashari
  • 1
  • 3