src/EntraideBundle/Controller/donController.php
/**
     * Creates a new don entity.
     *
     */
Creates a new don entity.
Creates a new don entity .
public function newAction(Request $request,$id)
    {
        $don = new Don();
        $form = $this->createForm('EntraideBundle\Form\donType', $don);
        $don->setDate(new \Datetime);
        $don->setUser($this->getUser());
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entraide = $em->getRepository("EntraideBundle:entraide")->find($id);
            $don->setEntraide($entraide);
            $em->persist($don);
            $em->flush($don);
            return $this->redirectToRoute('don_show', array('id' => $don->getId()));
        }
        return $this->render('don/new.html.twig', array(
            'don' => $don,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request , $ id ) { $ don = new Don ( ) ; $ form = $ this -> createForm ( 'EntraideBundle\Form\donType' , $ don ) ; $ don -> setDate ( new \ Datetime ) ; $ don -> setUser ( $ this -> getUser ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entraide = $ em -> getRepository ( " EntraideBundle:entraide " ) -> find ( $ id ) ; $ don -> setEntraide ( $ entraide ) ; $ em -> persist ( $ don ) ; $ em -> flush ( $ don ) ; return $ this -> redirectToRoute ( 'don_show' , array ( 'id' => $ don -> getId ( ) ) ) ; } return $ this -> render ( 'don/new.html.twig' , array ( 'don' => $ don , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new don entity.
Creates a new don entity .