src/EntraideBundle/Controller/entraideController.php
/**
     * Creates a new entraide entity.
     *
     */
Creates a new entraide entity.
Creates a new entraide entity .
public function newAction(Request $request)
    {
        $entraide = new Entraide();
        $form = $this->createForm('EntraideBundle\Form\entraideType', $entraide);
        $entraide->setDate(new Datetime);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $form['image']->getData()->move($entraide->getUploadRootDir(), $form['image']->getData()->getClientOriginalName());
            $entraide->setImage($form['image']->getData()->getClientOriginalName());
            $em = $this->getDoctrine()->getManager();
            $em->persist($entraide);
            $em->flush($entraide);
            return $this->redirectToRoute('entraide_show', array('id' => $entraide->getId()));
        }
        return $this->render('entraide/new.html.twig', array(
            'entraide' => $entraide,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ entraide = new Entraide ( ) ; $ form = $ this -> createForm ( 'EntraideBundle\Form\entraideType' , $ entraide ) ; $ entraide -> setDate ( new Datetime ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ form [ 'image' ] -> getData ( ) -> move ( $ entraide -> getUploadRootDir ( ) , $ form [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ entraide -> setImage ( $ form [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entraide ) ; $ em -> flush ( $ entraide ) ; return $ this -> redirectToRoute ( 'entraide_show' , array ( 'id' => $ entraide -> getId ( ) ) ) ; } return $ this -> render ( 'entraide/new.html.twig' , array ( 'entraide' => $ entraide , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new entraide entity.
Creates a new entraide entity .