src/EventsBundle/Controller/eventController.php
/**
     * Creates a new event entity.
     *
     */
Creates a new event entity.
Creates a new event entity .
public function newAction(Request $request)
    {
        $event = new Event();
        $form = $this->createForm('EventsBundle\Form\eventType', $event);
        $event->setUser($this->getUser());
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $form['image']->getData()->move($event->getUploadRootDir(), $form['image']->getData()->getClientOriginalName());
            $event->setImage($form['image']->getData()->getClientOriginalName());
            $em = $this->getDoctrine()->getManager();
            $em->persist($event);
            $em->flush($event);
            return $this->redirectToRoute('event_show', array('id' => $event->getId()));
        }
        else var_dump("foooooo");
        return $this->render('event/new.html.twig', array(
            'event' => $event,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ event = new Event ( ) ; $ form = $ this -> createForm ( 'EventsBundle\Form\eventType' , $ event ) ; $ event -> setUser ( $ this -> getUser ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ form [ 'image' ] -> getData ( ) -> move ( $ event -> getUploadRootDir ( ) , $ form [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ event -> setImage ( $ form [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ event ) ; $ em -> flush ( $ event ) ; return $ this -> redirectToRoute ( 'event_show' , array ( 'id' => $ event -> getId ( ) ) ) ; } else var_dump ( " foooooo " ) ; return $ this -> render ( 'event/new.html.twig' , array ( 'event' => $ event , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new event entity.
Creates a new event entity .