Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] IntegerType: reject submitted non-integer numbers#30329
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xabbuh commentedFeb 21, 2019
| Q | A |
|---|---|
| Branch? | 3.4 |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | #10240 |
| License | MIT |
| Doc PR |
xabbuh commentedFeb 21, 2019
Status: Needs work |
...ymfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| { | ||
| $decimalSeparator =$this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); | ||
| if (\is_string($value) &&false !==strpos($value,$decimalSeparator)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The transformation is invoked in reverse order inDateIntervalType when widget = integer, also in the model layer, so it could receive a real floating value here, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you give an example? I am not sure that I understand what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
symfony/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php
Lines 116 to 122 in5a3e894
| if ('integer' ===$options['widget']) { | |
| $childForm->addModelTransformer( | |
| newReversedTransformer( | |
| newIntegerToLocalizedStringTransformer() | |
| ) | |
| ); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
UnlikeIntegerType this transformation is invoked for model layer in reversed order, so I guess we should deal with real float values here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Basically, this is what I suggest:
if (false !==strpos((string)$value,$decimalSeparator)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Although, technically that should never happen becauseDateIntervalToArrayTransformer, so ignore my suggestion.
nicolas-grekas commentedFeb 23, 2019
Thank you@xabbuh. |
…xabbuh)This PR was merged into the 3.4 branch.Discussion----------[Form] IntegerType: reject submitted non-integer numbers| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#10240| License | MIT| Doc PR |Commits-------6a43e74 IntegerType: reject submitted non-integer numbers