Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2: handleRequest() is not submitting the form

Tags:

forms

php

symfony

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.

like image 828
Marek Avatar asked Jan 14 '14 21:01

Marek


1 Answers

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

like image 187
Leevi Graham Avatar answered Oct 24 '22 11:10

Leevi Graham