Skip to content

[Form] Allow NumberToLocalizedStringTransformer::reverseTransform to accept int/float #12470

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

Closed
wants to merge 1 commit into from

Conversation

boekkooi
Copy link
Contributor

Q A
Bug fix? not sure
New feature? not sure
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #12499
License MIT
Doc PR -

When adding a form type integer with a empty_data => 0 (aka with a int or float value) the form field will never validate correctly because the NumberToLocalizedStringTransformer will throw a TransformationFailedException because the value is not a string.

This PR fixes this problem by allowing int and float types as values in reverseTransform. Because the string only behavior was enforced by the transformer tests this is a BC change. (Personally I think that this is not a BC break that would cause problems).

Another possible fix is to add a normalizer for the empty_data option and transform a int or float to a LocalizedString but that looks/feels like a bad patch job.

I hope this PR will have less people going through there validation schema just to figure out that it's the NumberToLocalizedStringTransformer causing the problem.

@boekkooi
Copy link
Contributor Author

boekkooi commented Jan 9, 2015

@fabpot Is there any chance of getting this merged?

@hpatoio
Copy link
Contributor

hpatoio commented Jan 19, 2015

👍

@webmozart
Copy link
Contributor

Hi @boekkooi, thank you for taking the time to submit this PR! :) Unfortunately, I think that this is kind of a hack. The underlying problem is #4715, which cannot be fixed without BC breaks. Hopefully, we can fix #4715 in 3.0+, so that this issue will be fixed as well.

@boekkooi
Copy link
Contributor Author

@webmozart Thanks for having a look at this PR. I'm personally not convinced at all that this is a hack, so if you have the time could you maybe explain why you think that it is? (I tried to figure out what you mean based on #4715 but I'm not sure).

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

Successfully merging this pull request may close these issues.

4 participants