Adjunto el codigo de mi controlador:
Código PHP:
/**
* Creates a new SchoolRecord entity.
*
* @Route("/create", name="admission_school_record_applicant_create")
* @Method("POST")
* @Template("ABCAdmissionBundle:Applicant:applicant.html.twig")
*/
public function createAction(Request $request)
{ $em = $this->getDoctrine()->getManager("admission");
$session = $this->getRequest()->getSession();
$appId=$session->get('applicant');
$entity = new SchoolRecord();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
var_dump($request);
var_dump($request->request->get('fromDate'));
$applicantObject = $em->getRepository('ABCAdmissionBundle:Applicant')->find($appId);
$entity->setApplicant($applicantObject);
$app=$entity->getApplicant();
$entity->setCreatedDate(new DateTime());
$entity->setIsCurrent('true');
if ($form->isValid()) {
$em->persist($entity);
$em->flush();
$session = $this->getRequest()->getSession();
$session->set('step',4);
$session->set('applicant',$app->getId());
return $this->redirect($this->generateUrl('admission_applicants'));
}
// $session->set('step',3);
$session->set('applicant',$app->getId());
// return $this->redirect($this->generateUrl('admission_applicants'));
}