src/AmicaleBundle/Controller/AmicaleController.php
/**
     * Afficher un form  pour modifier  un Amicale
     *
     */
Afficher un form  pour modifier  un Amicale
Afficher un form pour modifier un Amicale
public function editAction(Request $request, Amicale $amicale)
    {
        $deleteForm = $this->createDeleteForm($amicale);
        $editForm = $this->createForm('AmicaleBundle\Form\AmicaleType', $amicale);
        $editForm->handleRequest($request);
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            if ($amicale->getImage() != null) {
                $editForm['image']->getData()->move($amicale->getUploadRootDir(), $editForm['image']->getData()->getClientOriginalName());
                $amicale->setImage($editForm['image']->getData()->getClientOriginalName());
                $this->getDoctrine()->getManager()->flush();
                return $this->redirectToRoute('amicale_edit', array('id' => $amicale->getId()));}
        }
        return $this->render('amicale/edit.html.twig', array(
            'amicale' => $amicale,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
public function editAction ( Request $ request , Amicale $ amicale ) { $ deleteForm = $ this -> createDeleteForm ( $ amicale ) ; $ editForm = $ this -> createForm ( 'AmicaleBundle\Form\AmicaleType' , $ amicale ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { if ( $ amicale -> getImage ( ) != null ) { $ editForm [ 'image' ] -> getData ( ) -> move ( $ amicale -> getUploadRootDir ( ) , $ editForm [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ amicale -> setImage ( $ editForm [ 'image' ] -> getData ( ) -> getClientOriginalName ( ) ) ; $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirectToRoute ( 'amicale_edit' , array ( 'id' => $ amicale -> getId ( ) ) ) ; } } return $ this -> render ( 'amicale/edit.html.twig' , array ( 'amicale' => $ amicale , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ) ; }
Afficher un form  pour modifier  un Amicale
Afficher un form pour modifier un Amicale