-
Notifications
You must be signed in to change notification settings - Fork 702
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
Enable or disable removing false data for JsonToFormDecoder #883
Enable or disable removing false data for JsonToFormDecoder #883
Conversation
`fos_rest.decoder.jsontoform` removes false values. In the case you have a form with just one checkbox or need to patch one checkbox it does not work. Instead of remove false value you can transform it to null. For this you need to override a parameter: | ||
```yaml | ||
parameters: | ||
fos_rest.decoder.jsontoform.remove_false_data: false |
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.
if we do add thigs feature, then this should be handled via the DI extension
I always have concerns about adding options that have a global effect since it means that people combining different Bundles that require different config will run into trouble. at the same time adding more features that are configured by path etc add overhead. sigh :-/ |
This limitation only occurs when using the
As the role of |
👍 |
I never used the decoder myself but I guess this could be argued to be a bug fix rather than a BC break .. |
@lsmith77 I haven't the same idea: if some one was using this decoder before this change, and was testing values for instance with That's why I think that the idea of @meyerbaptiste was acceptable: it don't introduce BC break but allow to fix the issue, and also allow to change this default behaviour (that is now |
Enable or disable removing false data for JsonToFormDecoder
OK, now how I cannot distinguish empty field from false field? No chance |
The
JsonToFormDecoder
class remove false data like a classic form.But, in the case where we have a form with just one checkbox or patch just one checkbox it does not work because form is not submitted due to missing of parameters in the request and so it is invalid.
This issue can be fixed by replacing the value by null instead of remove it.
So in this PR I propose that we add a container parameter for this service which can enable or disable removing false data.
I use a container parameter because it is a tricky case which does not require to implement a configuration system of the decoder but which leaves the possibility to the developer to modify it if necessary.