public function addStudentAction(Request $request) { $data = json_decode($request->getContent()); $em = $this->getDoctrine()->getManager(); $educationForm = $em->getRepository('AppBundle:EducationForm')->find($data->educationForm); $group = $em->getRepository('AppBundle:Group')->find($data->group); $sex = $em->getRepository('AppBundle:Sex')->find($data->sex); $student = new Student(); $student->setEducationForm($educationForm); $student->setGroupa($group); $student->setFirstName($data->firstName); $student->setLastName($data->lastName); $student->setSex($sex); $student->setDisabled(0); $em->persist($student); $em->flush(); return new JsonResponse($student->jsonSerialize()); }