src/Cpm/JovenesBundle/Controller/CicloController.php
/**
     * Creates a new Ciclo entity.
     *
     * @Route("/create", name="ciclo_create")
     * @Method("post")
     * @Template("CpmJovenesBundle:Ciclo:new.html.twig")
     */
Creates a new Ciclo entity.
Creates a new Ciclo entity .
public function createAction()
    {
        $entity  = new Ciclo( $this->getJYM()->getEtapaInicial() );
        $request = $this->getRequest();
        $form    = $this->createForm(new CicloType(), $entity);
        $form->bindRequest($request);
        if ($form->isValid()) {
            try{
            	$em = $this->getDoctrine()->getEntityManager();
            	$em->persist($entity);
            	$em->flush();
				return $this->redirect($this->generateUrl('ciclo_show', array('id' => $entity->getId())));
			}catch(\PDOException $e){
			    $this->setErrorMessage("No se pudo crear el ciclo, compruebe que no exista un ciclo del mismo Año  ({$e->getMessage()})");
			}
        }
        return array(
            'entity' => $entity,
            'form'   => $form->createView()
        );
    }
public function createAction ( ) { $ entity = new Ciclo ( $ this -> getJYM ( ) -> getEtapaInicial ( ) ) ; $ request = $ this -> getRequest ( ) ; $ form = $ this -> createForm ( new CicloType ( ) , $ entity ) ; $ form -> bindRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { try { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ciclo_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } catch ( \ PDOException $ e ) { $ this -> setErrorMessage ( " No se pudo crear el ciclo, compruebe que no exista un ciclo del mismo Año  ({ $ e - >g etMessage( ) } ) " ) ; } } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) ) ; }
Creates a new Ciclo entity.
Creates a new Ciclo entity .