Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Form] Addmodel_type option toMoneyType#19359

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:7.1frommdoutreluingne:fix-19353
Jan 15, 2024

Conversation

@mdoutreluingne
Copy link
Contributor

Fixes#19353

@mdoutreluingne
Copy link
ContributorAuthor

mdoutreluingne commentedDec 30, 2023
edited
Loading

It seems that the names of the options are arranged in alphabetical order, but I'm not sure,can you confirm this?

@OskarStark
Copy link
Contributor

can you confirm this?

Yes

mdoutreluingne reacted with thumbs up emoji

@OskarStarkOskarStark changed the title[Form] add "model_type" option to MoneyType[Form] Addmodel_type option toMoneyTypeDec 30, 2023
@mdoutreluingne
Copy link
ContributorAuthor

Ok, I'll do that in another PR targeting branch5.4

..caution::

When the value is set to ``integer``, the ``divisor`` option must not be set to ``1``,
to avoid losing decimals during 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.

The reason looks confusing to me. How is it possible to lose decimals when the divisor is1?

Looking at the implementation, it seems more related to the fact that theinteger value doesn't have any effect when the divisor is1.

Copy link
ContributorAuthor

@mdoutreluingnemdoutreluingneDec 31, 2023
edited
Loading

Choose a reason for hiding this comment

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

I misspoke, it is in fact linked to theinteger with a divisor is1.

I find that the caution message is no longer useful. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@mdoutreluingne I still don't understand this caution. But it's not because of your PR. I've checked the code and I don't understand it either. I also read this discussion and I still don't understand it:symfony/symfony#51884 (comment)

How would you explain this in a way that anybody can understand it? Thanks.

Copy link
ContributorAuthor

@mdoutreluingnemdoutreluingneJan 2, 2024
edited
Loading

Choose a reason for hiding this comment

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

@javiereguiluz

From what I've understood from looking at the implementation, an exception is thrown if themodel_type isinteger and the divisor is1, because according tothis condition the casting is only done if the divisor is not equal to1, otherwise it only returns the value entered.

Me too, I don't understand why an exception is thrown if the divisor equals1. Casting can be done perfectly well if the divisor is equal to1.

I've added this caution message to warn the reader that if he changes themodel_type forinteger, he must also change thedivisor (because the default divisor value is1), otherwise an exception will be thrown.

But maybe I've added a message that is ultimately of no interest to the reader and the message of the exception is enough.

What do you think?

Copy link
Member

@javiereguiluzjaviereguiluzJan 3, 2024
edited
Loading

Choose a reason for hiding this comment

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

Yes, I think it's better to not add this to the docs. Developers will get a explict exception message if they do "wrong".

But, maybe we should revisit this or refactor the code to make it easier to understand. It seems that nobody truly understands this code 😐

yceruto reacted with thumbs up emoji
Copy link
ContributorAuthor

@mdoutreluingnemdoutreluingneJan 3, 2024
edited
Loading

Choose a reason for hiding this comment

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

Removing caution message done.

I agree, I think it should be refactor the code to make it easier to understand.

Choose a reason for hiding this comment

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

I've openedsymfony/symfony#53488 to see if we can finally understand the reason of this code. Thanks.

@javiereguiluz
Copy link
Member

Thanks Maxime! I've merged this because your contribution is complete and we don't need to wait to fixsymfony/symfony#53488. Thanks.

mdoutreluingne reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

+1 more reviewer

@ycerutoycerutoyceruto left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

[Form] add "model_type" option to MoneyType

5 participants

@mdoutreluingne@OskarStark@javiereguiluz@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp