-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[3.0] [Form] IntegerType accepts floats - a bit misleading #10240
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
Comments
I also noticed an issue with this today where you cannot render an The HTML5 number input does support decimals, and this should be reflected in either the ping @webmozart |
See #8106 |
Just adding my opionion about the validation rules: An integer is an integer. Every |
The symfony form number type should also have a "step" option that would than be mapped to the html5 input type="number" step option. Than it would e.g. be possible to have float numbers that would only be a full number or a .5 number with step=".5" |
Another year has passed and still nothing has happend here. I can confirm that At this point this might be worth noting: /src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig#L135 I'd love to see this corrected in the next version because especially on smartphones it's more convenient to have it as Also see #8106 which basically states the same as this issue. |
@ghost |
@stof yes sure. But if NumberType would render into |
I think the field types have moved on slightly since this was opened, but now there is the issue of I doubt this will ever be changed now as it would break BC |
Isn't it an option to add a |
Just came across this issue. It really doesn't make any sense to me that |
…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
The
IntegerType
supports floats, but as the name suggests it should only accept integers, i.e. whole numbers.The
NumberType
supports floats, locale specific numeric strings (e.g. "40,000") etc.I propose a change to these 2 types:
IntegerType
: should be used for whole integers as the name suggestsNumberType
: should be used for floats (rendering as aninput[type="number"]
), and have a new option (support_locale_strings
or something similar) so that it renders asinput[type="text"]
and has the relevant attachedNumberToLocalizedStringTransformer
.This is obviously a BC break so marked it for 3.0.
The text was updated successfully, but these errors were encountered: