Skip to content

Instantly share code, notes, and snippets.

@andreia
Created December 30, 2012 18:05
Show Gist options
  • Select an option

  • Save andreia/4414190 to your computer and use it in GitHub Desktop.

Select an option

Save andreia/4414190 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