Symfony2 FOSRest value for null
In a web application built with Symfony2, I need to send values null
as part of a request PUT
or PATCH
FOSRestBundle endpoint. for example { "available": null }
. A database field is a type nullable
boolean
that is set by Doctrine. So the value must be 1, 0 or null
(i.e. Unknown). However, sending the value is null
ignored. This can be a problem with either Symfony2 forms or FOSRest. I tried adding to the form empty_value => null
and empty_data => null
but nothing works. Any idea if there is a parameter that allows it to be accepted null
as an option?
source to share
Boolean true or false is usually how you can tell it was canceled because it was null or unchecked because it was false, it is false anyway. So if you want the 3 options to use the select box better than the checkbox, use (Select, Yes, No) with the values (null, 1, 0).
You can check it out, but I don't think it helps much https://github.com/symfony/symfony/issues/10364
source to share