Exemplo n.º 1
0
 /**
  * @Route("/group/{id}/add-student", name="app_agroup_add_student")
  * @Template()
  */
 public function addStudentAction(Request $request, AGroup $agroup)
 {
     $student = new Student();
     $student->setAgroup($agroup);
     $form = $this->createForm(new StudentType(), $student);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $student = $form->getData();
         $em = $this->getDoctrine()->getManager();
         $em->persist($student);
         $em->flush();
         return $this->redirectToRoute('app_agroup_show', ['id' => $agroup->getId()]);
     }
     return ['form' => $form->createView()];
 }