I have a big entity and a big form. When updating my entity, I only render parts of my form, through ajax calls. On client side, I\'m using Jquery and html5 FormData
You are absolutely right, Symfony will ignore it if method is PATCH because of this line in Request Handler:
$form->submit($data, 'PATCH' !== $method);
Now, I would generally suggest that you use a PUT
request if that is an option, but if it isn't then second argument to FormInterface::submit($submittedData, $clearMissing = true)
is what you're after.
The "proper" way would probably be to make your own implementation of Symfony\Component\Form\RequestHandlerInterface which would force $clearMissing
to be true
.
Other, way is a lot easier but might not work for all use-cases: use $form->submit()
directly.
If you have the following code:
$form->handleRequest($request);
You can do:
$form->submit($request->get($form->getName()), true);
You can also omit second parameter since true
is the default value