/**
  * @Route("/task", name="task")
  */
 public function newAction(Request $request)
 {
     $task = new Task();
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->name = 'tag1';
     $task->getTags()->add($tag1);
     $tag2 = new Tag();
     $tag2->name = 'tag2';
     $task->getTags()->add($tag2);
     // end dummy code
     $form = $this->createForm(TaskType::class, $task, array('action' => $this->get('router')->generate('task')));
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         $this->addFlash('notice', 'Your changes were saved!');
     }
     return $this->render('AppBundle:Task:new.html.twig', array('form' => $form->createView()));
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  * @Route("/new-task")
  */
 public function newAction(Request $request)
 {
     $task = new Task();
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $task->getTags()->add($tag1);
     $tag2 = new Tag();
     $tag2->setName('tag2');
     $task->getTags()->add($tag2);
     // end dummy code
     $form = $this->createForm(new TaskType(), $task);
     $form->handleRequest($request);
     if ($form->isValid()) {
         // ... maybe do some form processing, like saving the Task and Tag objects
         $em = $this->getDoctrine()->getManager();
         $task = $form->getData();
         $em->persist($task);
         $em->flush();
     }
     return $this->render('new.html.twig', array('form' => $form->createView()));
 }