public function crudUpdate(Request $request, $id)
    {
        try{
            $entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));

            $form = $this->createForm($this->getEntityType(), $entity);
            $form->submit($request);
            
            $page = static::EDIT_VIEW;
            
            if ($form->isValid()) {
                $page = static::SHOW_VIEW;
                $this->saveEntity($entity);
                $form = $this->createDeleteForm($id)->createView();
                return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
            }
            
            $form = $form->createView();
            $delete_form = $this->createDeleteForm($id)->createView();
            return $this->success($page, $this->commonsResponseVars(compact('entity','form','delete_form')));
            
        }catch(\Exception $e){
            return $this->failure($e);
        }
    }
public function crudUpdate(Request $request, $id)
    {
        try{
            $entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));

            $form = $this->createForm($this->getEntityType(), $entity);
            $form->submit($request);
            
            $page = static::EDIT_VIEW;
            
            if ($form->isValid()) {
                $page = static::SHOW_VIEW;
                $this->saveEntity($entity);
                $form = $this->createDeleteForm($id)->createView();
                return $this->render($page, $this->commonsResponseVars(compact('entity','form')));
            }
            
            $form = $form->createView();
            $delete_form = $this->createDeleteForm($id)->createView();
            return $this->success($page, $this->commonsResponseVars(compact('entity','form','delete_form')));
            
        }catch(\Exception $e){
            return $this->failure($e);
        }
    }
public function crudUpdate ( Request $ request , $ id ) { try { $ entity = $ this -> throwEntityNotFoundException ( $ this -> getRepository ( ) -> find ( $ id ) ) ; $ form = $ this -> createForm ( $ this -> getEntityType ( ) , $ entity ) ; $ form -> submit ( $ request ) ; $ page = static :: EDIT_VIEW ; if ( $ form -> isValid ( ) ) { $ page = static :: SHOW_VIEW ; $ this -> saveEntity ( $ entity ) ; $ form = $ this -> createDeleteForm ( $ id ) -> createView ( ) ; return $ this -> render ( $ page , $ this -> commonsResponseVars ( compact ( 'entity' , 'form' ) ) ) ; } $ form = $ form -> createView ( ) ; $ delete_form = $ this -> createDeleteForm ( $ id ) -> createView ( ) ; return $ this -> success ( $ page , $ this -> commonsResponseVars ( compact ( 'entity' , 'form' , 'delete_form' ) ) ) ; } catch ( \ Exception $ e ) { return $ this -> failure ( $ e ) ; } }
Edits an existing entity.

@param \Symfony\Component\HttpFoundation\Request $request
@param type $id
@return type
Edits an existing entity .