Skip to content

Instantly share code, notes, and snippets.

@enricostano
Created July 10, 2012 22:33
Show Gist options
  • Save enricostano/3086648 to your computer and use it in GitHub Desktop.
Save enricostano/3086648 to your computer and use it in GitHub Desktop.
AttachmentController
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