简体   繁体   English

Symfony2:handleRequest()没有提交表单

[英]Symfony2: handleRequest() is not submitting the form

I have got strange problem with handleRequest method in Symfony 2.3.5. 我在Symfony 2.3.5中遇到了handleRequest方法的奇怪问题。

I am submitting form with handleRequest ($editForm->handleRequest($request)) and everything is working fine on dev. 我正在使用handleRequest($ editForm-> handleRequest($ request))提交表单,并且一切正常。 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? 但有人可以告诉我为什么handleRequest在prod环境中对我不起作用?

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时设置方法参数吗?

$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_method_override http://symfony.com/doc/current/reference/configuration/framework.html#http-method-override http://symfony.com/doc/current/reference/configuration/framework.html#http-method-override

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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