silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
722 stars 821 forks source link

MoneyField: Move field generation from constructor to custom method #11153

Closed beerbohmdo closed 7 months ago

beerbohmdo commented 7 months ago

Description

The MoneyField is a CompositeField which contains two fields, a DropdownField/HiddenField/TextField for the currency and a NumberField for the Amount. The first is already created inside a buildCurrencyField() method. The amount Field is directly created inside the constructor.

I would suggest to move the generation of the Amount field into a method also. This makes the class more extensible.

My use case is that I wanted to store the Money as full integer instead decimal, like my (and the most other) payment provider does. So I had to replace the internal NumericField with my own.

Additional context or points of discussion

In this PR https://github.com/silverstripe/silverstripe-framework/pull/11150 I already made that change.

Validations

PRs

GuySartorelli commented 7 months ago

The linked PR has been merged. This will be included in the Silverstripe CMS 5.2.0 release in April.