Exemplo n.º 1
0
 /**
  * 
  * @Route("/admin/feature/new/{featureSectionId}", name="admin_feature_new")
  */
 public function newAction(Request $request, $featureSectionId)
 {
     $feature = new Feature();
     $featureSection = $this->getDoctrineRepo('AppBundle:FeatureSection')->find($featureSectionId);
     $feature->setFeatureSection($featureSection);
     //when the form is posted this method prefills entity with data from form
     $form->handleRequest($request);
     if ($form->isValid()) {
         //check if there is file
         $em = $this->getDoctrine()->getManager();
         // save to db
         $em->persist($feature);
         $em->flush();
         return $this->redirect($this->generateUrl('admin_feature_list', array('featureSectionId' => $featureSectionId)));
     }
     return $this->render('admin/feature/new.html.twig', array('form' => $form->createView(), 'featureSectionId' => $featureSectionId));
 }