/**
{% block phpdoc_method_header %}
     * Displays a form to edit an existing {{ entity }} entity.
{% endblock phpdoc_method_header %}
     *
{% block phpdoc_method_annotations %}
{% if 'annotation' == format %}
     * @Route("/{id}/edit", name="{{ route_name_prefix }}_edit")
     * @Method({"GET", "POST"})
{% endif %}
{% endblock phpdoc_method_annotations %}
     */
{% block method_definition %}
    public function editAction(Request $request, {{ entity_class }} ${{ entity_singularized }})
{% endblock method_definition %}
    {
{% block method_body %}
        $deleteForm = $this->createDeleteForm(${{ entity_singularized }});
        $editForm = $this->createForm('{{ namespace }}\Form\{{ entity_class }}Type', ${{ entity_singularized }});
        $editForm->handleRequest($request);
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist(${{ entity_singularized }});
            $em->flush();
            return $this->redirectToRoute('{{ route_name_prefix }}_edit', array('id' => ${{ entity_singularized }}->getId()));
        }
{% endblock method_body %}
{% block method_return %}
        return $this->render('{{ entity|lower|replace({'\\': '/'}) }}/edit.html.twig', array(
            '{{ entity_singularized }}' => ${{ entity_singularized }},
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
{% endblock method_return %}
    }
 
  |