Nizar B.
Nizar B.

Reputation: 3118

POST error 500: Internal server error

I'm trying to build a form with Symfony2 and when I click on my button to submit the form, i get a POST method with a 500 Internal server error.

Here is the code on my controller to validate the form:

if ($request->getMethod() == 'POST')
    {
        $form->bindRequest($request);
        if ($form->isValid())
        {

            $em = $this->getDoctrine()->getEntityManager();             
            $em->persist($group);
            $em->flush();
            return $this->redirect($this->generateUrl('index'));
        }
    }

In the view:

    <form action="{{ path('new') }}" method="post" {{ form_enctype(form) }}>
<div class="actions">
          <input type="submit" value="OK"/>
        </div>

But I receive nothing from the form. Someone can help me please ? This really weird bug.

Upvotes: 2

Views: 6529

Answers (1)

sensi
sensi

Reputation: 569

I also had the same issue with the form handling.

The solution is to clear the cache manually and warm up it again.

php app/console cache:clear ==> Does'nt work for me, so I do:
rm -rf app/cache/dev
php app/console cache:warmup

That fix the problem!

But what was the issue? I figure out that 500 Internal Server Error get's thrown becaus it try's to load the cached routing values in app/cache/dev/annotations (in my case)

Hint: I have used annotation for templating and routing before in the controller. Than I've chang this and now I'm using external file routing... And that was my pain... I've forgotten to clear the cache manually!!!

Upvotes: 3

Related Questions