/** * @Route("/add_meta/{destination}", name="add_meta") */ public function add_metaAction(Request $request, $destination) { $trip = new Destination(); $trip->setDestination($destination); $trip->setName($this->get('security.token_storage')->getToken()->getUser()); $trip->setCreationDate(); $trip->setModifyDate(); $form = $this->createFormBuilder($trip)->add('departure_date', 'date')->add('arrival_date', 'date')->add('insert', 'submit', array('label' => 'Invia'))->getForm(); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $em = $this->getDoctrine()->getManager(); $em->persist($trip); $em->flush(); return $this->redirectToRoute('profile'); } // replace this example code with whatever you need return $this->render('AppBundle::add_meta.html.twig', array("destination" => $destination, 'form' => $form->createView())); }