Skip to content

[Form] INT64 cast to float in IntegerType on reverseTransform #18067

Closed
@ovrflo

Description

@ovrflo

Hello,

I found a bug in the IntegerType of the Form (Symfony 2.8, btw). My setup includes a Doctrine Entity and an associated FormType. The entity includes a BIGINT field which brings me to the problem. When I'm submitting the form, most (but not all) values I enter in the BIGINT field get decremented by 1 (maybe even 2 sometimes, I'm not sure).

I traced the issue down to NumberToLocalizedStringTransformer::reverseTransform which calls $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE, $position). Now, this call leads to Symfony\Component\Intl\NumberFormatter\NumberFormatter::convertValueDataType which for TYPE_DOUBLE casts to float...

Now, I would like to know if this is a bug and if I should fix it. I'm thinking of changing NumberToLocalizedStringTransformer::reverseTransform to detect if the number is float and if it's not, to default to INT or INT64 (depending on architecture maybe ?).

What do you guys think ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions