Guest User

Untitled

a guest
Mar 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public function agregar(Request $request)
  2. {
  3. $persona = new Persona();
  4. $formulario = $this->createForm(PersonaType::class,$persona);
  5. // $this->render('base.html.twig',array("persona"=>$formulario->createView()));
  6. $formulario->handleRequest($request);
  7. if($formulario -> isSubmitted() && $formulario->isValid())
  8. {
  9. $persona = $formulario->getData();
  10.  
  11. $db = $this->getDoctrine()->getManager();
  12. $db->persist($persona);
  13. $db->flush();
  14.  
  15. return new Response('<html>hola </html>');
  16. }
  17. else
  18. {
  19. return new Response('<html>chau </html>');
  20. }
  21. }
  22.  
  23. /**
  24. * @Route("/post", name="post_list")
  25. */
  26. public function mostar()
  27. {
  28. $formulario = $this->createForm(PersonaType::class);
  29. return $this->render('base.html.twig',array("persona"=>$formulario->createView()));
  30. }
  31.  
  32. <h2>Formulario con Symfony3</h2>
  33. {{form(persona)}}
  34. {{form_end(persona)}}
Add Comment
Please, Sign In to add comment