Created
July 10, 2012 22:33
-
-
Save enricostano/3086648 to your computer and use it in GitHub Desktop.
AttachmentController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function createAction($ownerObj) | |
{ | |
$attachment = new Attachment(); | |
$ownerObj->addAttachment($attachment); | |
$request = $this->getRequest(); | |
$form = $this->createForm(new AttachmentType(), $attachment); | |
if ($request->getMethod() == 'POST') { | |
if ($form->isValid()) { | |
$em = $this->getDoctrine() | |
->getEntityManager(); | |
$em->persist($attachment); | |
$em->persist($ownerObj); | |
$em->flush(); | |
return $this->redirect($this->generateUrl('StanoSasDocumentBundle_gara_show', array( $ownerObj->getId() ))); | |
} | |
} | |
return $this->render('StanoSasDocumentBundle:Attachment:form', array( | |
'ownerObj' => $ownerObj, | |
'form' => $form->createView() | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment