Skip to content

Instantly share code, notes, and snippets.

@Narven
Forked from andreia/gist:4414190
Created June 17, 2014 02:35
Show Gist options
  • Save Narven/72173460541c8046d08a to your computer and use it in GitHub Desktop.
Save Narven/72173460541c8046d08a to your computer and use it in GitHub Desktop.
<?php
try{
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->get('session')->setFlash('notice', 'Article inserted!');
return $this->redirect($this->generateUrl('article_show', array('id' => $entity->getId())));
}catch(\Exception $e){
// log $e->getMessage()
$this->get('session')->setFlash('error', "Can't insert the article.");
}
return $this->render('MyTestBundle:Article:new.html.twig', array(
'entity' => $entity,
'form' => $form->createView(),
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment