Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function agregar(Request $request)
- {
- $persona = new Persona();
- $formulario = $this->createForm(PersonaType::class,$persona);
- // $this->render('base.html.twig',array("persona"=>$formulario->createView()));
- $formulario->handleRequest($request);
- if($formulario -> isSubmitted() && $formulario->isValid())
- {
- $persona = $formulario->getData();
- $db = $this->getDoctrine()->getManager();
- $db->persist($persona);
- $db->flush();
- return new Response('<html>hola </html>');
- }
- else
- {
- return new Response('<html>chau </html>');
- }
- }
- /**
- * @Route("/post", name="post_list")
- */
- public function mostar()
- {
- $formulario = $this->createForm(PersonaType::class);
- return $this->render('base.html.twig',array("persona"=>$formulario->createView()));
- }
- <h2>Formulario con Symfony3</h2>
- {{form(persona)}}
- {{form_end(persona)}}
Add Comment
Please, Sign In to add comment