Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] add "model_type" option to MoneyType #51884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2023

Conversation

garak
Copy link
Contributor

@garak garak commented Oct 7, 2023

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #50707
License MIT

This is a replacement for abandoned #50720

Please notice that the previous PR misunderstood the related issue: the intended casting should be applied when the divisor is not 1, otherwise it doesn't make sense.

@garak garak requested review from xabbuh and yceruto as code owners October 7, 2023 16:51
@carsonbot carsonbot added this to the 6.4 milestone Oct 7, 2023
@garak garak force-pushed the moneytype_new_option branch from eae8a80 to dd0c07d Compare October 7, 2023 17:10
@OskarStark OskarStark added the Form label Oct 7, 2023
@carsonbot carsonbot changed the title add "model_type" option to MoneyType [Form] add "model_type" option to MoneyType Oct 7, 2023
Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Massimiliano for this improvement! I left a minor request.

@garak
Copy link
Contributor Author

garak commented Oct 29, 2023

@xabbuh could you review, please?

@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a line in the chagelog of the component in section 7.1


$resolver->setNormalizer('model_type', static function (Options $options, $value) {
if ('integer' === $value && 1 === $options['divisor']) {
throw new LogicException('Can use integer "model_type" option only when the "divisor" option is not 1.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new LogicException('Can use integer "model_type" option only when the "divisor" option is not 1.');
throw new LogicException('When the "model_type" option is set to "integer", the "divisor" option should not be set to "1".');

but why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if you set the divisor to 1, you can end up with a float instead of an integer, and lose decimals in the casting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry I don't get it. Also the original PR had exactly the opposite : throwing when the divisor is not 1.
https://github.com/symfony/symfony/pull/50720/files#diff-eb30dc48f2b749fa5d76ce9598bb51c00fcb97bd7a10337f0630db00f5ba3b9aR100

I'm pretty sure I'm missing something 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, and indeed I added a note about that when I opened this PR.

@garak
Copy link
Contributor Author

garak commented Nov 25, 2023

Please add a line in the chagelog of the component in section 7.1

I see no changelog for 7.1, should I create a new file?

@nicolas-grekas
Copy link
Member

@fabpot fabpot force-pushed the moneytype_new_option branch from e5dfc53 to 8811741 Compare December 29, 2023 07:55
@fabpot
Copy link
Member

fabpot commented Dec 29, 2023

Thank you @garak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new option to MoneyType
6 participants