I have a strange problem with Symfony (v 2.3.2) form. It's very simple form without relations. I should also noted that this form is used in REST API only.
So I have a published field (boolean). On the entity it's set to false by default.
On update, the REST API client sends PUT request which is correct aka ...&[entity]published=0&.... This value is also shown in Symfony profiler in the form parameters.
However I've noticed that the actual value in database is set to true (or 1 as it's tinyint).
So, to find out what's the problem, I added throw statement after $form->submit($request);
throw new \Exception(sprintf('Request: %s, form: %s', $request->get('entity')['published'], $form->get('published')->getData()));
or
throw new \Exception(sprintf('Request: %s, form: %s', $request->get('entity')['published'], $form->getData()->getPublished()));
The exception message says: Request: 0, form: 1. It means that somewhere in submit method the string value '0' is converted to 1.
The field is constructed with $builder->add('published', 'checkbox', [ 'required' => false ])
Also I've noticed strange thing, which may be related. On the Symfony profiler, panel request, I'm getting error: Warning: json_encode(): Invalid UTF-8 sequence in classes.php line 3758, I'm not sending any strange characters - just word "test".