You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NumberType will actually round the model. The PercentType one will ignore this scale and keep every decimals in the model.
But the view will then show:
Leading to something strange, in my opinion.
Having the same behaviour for both would be great, or changing the name of this parameter in PercentType to make this difference clearer like view_scale for example.
Thanks!
The text was updated successfully, but these errors were encountered:
I wanted to add that the scale parameter is required in PercentType (in PercentToLocalizedStringTransformer you will see that $scale is set to 0 if null is provided). But in NumberType, it's fine to ignore the scale and NumberToLocalizedStringTransformer will ignore the rounding process). There is no reason to require a scale, sometimes it's just not necessary.
Description
Parameter
scale
ofPercentType
is a bit confusing when you know how it works for theNumberType
one:NumberType
will round the submitted value, meaning the model will be rounded too; What's saved and what's shown in the view is identical.PercentType
will round the view only, but will save the model with all the decimals sent.Example
Consider this form:
Then submit values with more decimals than the scale is set to and dump the model:
Something like:
The
NumberType
will actually round the model. ThePercentType
one will ignore this scale and keep every decimals in the model.But the view will then show:
Leading to something strange, in my opinion.
Having the same behaviour for both would be great, or changing the name of this parameter in
PercentType
to make this difference clearer likeview_scale
for example.Thanks!
The text was updated successfully, but these errors were encountered: