TheBigBrainsCompany / TbbcMoneyBundle

This bundle is used to integrate the Money library (https://github.com/mathiasverraes/money) into a Symfony project. This library is based on Fowler's Money pattern (https://verraes.net/2011/04/fowler-money-pattern-in-php/)
MIT License
192 stars 74 forks source link

feat: improve currency type (append local aware curreny name in label) #174

Open Chris53897 opened 5 months ago

Chris53897 commented 5 months ago

https://github.com/TheBigBrainsCompany/TbbcMoneyBundle/issues/171

I am not sure what is the best way to implement it. With this implementation it is an opt-in for the longer labels.

Default

before-only-code

With local currency name (german)

after-locale-name

Usage: ->add('currency', CurrencyType::class, ['label' => 'foo', 'currency_choices_label_format' => 1])

johanwilfer commented 5 months ago

Makes sense but maybe you can add constants and documentation for these new options as well? If possible a unit test as well?

Chris53897 commented 5 months ago

I can to. Maybe Enum instead of Constants. But maybe i will find a better way to implement it. getLabel(...) that can be overwritten by the Users. I will need to have a look if this works and is easy to implement.

johanwilfer commented 5 months ago

Another idea is to use placeholders similar to how it works in translations maybe? And we can have:

And then we can have a string instead to define the format/template to use, and it is very easy to extend maybe? (Default could then be %code% as that is the current default.

johanwilfer commented 1 month ago

Is this something you plan to work on @Chris53897 or should we close it?

Chris53897 commented 1 month ago

The earliest possible time for open source work is end of september for me. I will try to have a look at your placeholder idea.

johanwilfer commented 1 month ago

Thanks @Chris53897 - will leave this open then :)