/** * Creates a new Person entity. * @Template() * @Secure(roles="ROLE_USER") */ public function createajaxAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = ContactManager::create('Person'); $form = $this->createForm(new PersonType(), $entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); if ($entity->getAddress() !== null) { $em->persist($entity->getAddress()); } $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('jlm_contact_ajax_person_show', array('id' => $entity->getId()))); } return array('entity' => $entity, 'form' => $form->createView()); }
/** * Creates a new Trustee entity. * * @Template("JLMModelBundle:Trustee:contactnew.html.twig") * @Secure(roles="ROLE_USER") */ public function contactcreateAction(Trustee $trustee) { $em = $this->getDoctrine()->getManager(); $entity = ContactManager::create('Person'); $request = $this->getRequest(); $form = $this->createForm(new PersonType(), $entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $trustee->addContact($entity); $em->persist($entity); $em->persist($trustee); $em->flush(); return $this->redirect($this->generateUrl('trustee_show', array('id' => $trustee->getId()))); } return array('trustee' => $trustee, 'entity' => $entity, 'form' => $form->createView()); }