简体   繁体   中英

Symfony2: handleRequest() is not submitting the form

I have got strange problem with handleRequest method in Symfony 2.3.5.

I am submitting form with handleRequest ($editForm->handleRequest($request)) and everything is working fine on dev. But on prod environment it is not working. I have debug everything and I found that it is not submitting this form.

I have managed to get this working with changing

$editForm->handleRequest($request)

to

$editForm->submit($request->request->get($editForm->getName()))

But could someone tell me why handleRequest is not working for me just in prod environment?

I have removed all cache.

EDIT: I have also remind myself that it is working great on creating, but not on editing/updating.

Are you setting the method param when creating your $editForm?

$editForm = $this->createForm(new TaskType(), $task, array(
    'action' => $this->generateUrl('edit_task'),
    'method' => 'PUT',
));

$editForm->handleRequest($request);

Additionally you might need to set http_method_override in your config. http://symfony.com/doc/current/reference/configuration/framework.html#http-method-override

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM