1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public function editAction(Request $request)
{
$id = $request->request->get('id');
$em = $this->getDoctrine()->getManager();
$persRepository = $this->getDoctrine()->getRepository('AppBundle:Pers');
$pers=$persRepository->findById($id);
$editForm = $this->createForm(PersType::class, $pers);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('home');
}
return $this->render('edit.html.twig', array(
'pers' => $pers,
'edit_form' => $editForm->createView(),
));
} |