src/PN/Bundle/UserBundle/Controller/Administration/UserController.php
/**
     * Displays a form to edit an existing user entity.
     *
     * @Route("/{id}/edit", name="user_edit", methods={"GET", "POST"})
     */
Displays a form to edit an existing user entity.
Displays a form to edit an existing user entity .
public function editAction(Request $request, User $user) {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');
        $userManager = $this->get('fos_user.user_manager');
        $form = $this->createForm(UserType::class, $user);
        $form->remove("role");
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $userName = $this->get('user')->getUserName();
            $user->setModifiedBy($userName);
            $userManager->updateUser($user);
            $this->addFlash('success', 'Successfully updated');
            return $this->redirectToRoute('user_edit', array('id' => $user->getId()));
        }
        return $this->render('user/admin/user/edit.html.twig', array(
                    'user' => $user,
                    'edit_form' => $form->createView(),
        ));
    }
public function editAction ( Request $ request , User $ user ) { $ this -> denyAccessUnlessGranted ( 'ROLE_ADMIN' ) ; $ userManager = $ this -> get ( 'fos_user.user_manager' ) ; $ form = $ this -> createForm ( UserType :: class , $ user ) ; $ form -> remove ( " role " ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ userName = $ this -> get ( 'user' ) -> getUserName ( ) ; $ user -> setModifiedBy ( $ userName ) ; $ userManager -> updateUser ( $ user ) ; $ this -> addFlash ( 'success' , 'Successfully updated' ) ; return $ this -> redirectToRoute ( 'user_edit' , array ( 'id' => $ user -> getId ( ) ) ) ; } return $ this -> render ( 'user/admin/user/edit.html.twig' , array ( 'user' => $ user , 'edit_form' => $ form -> createView ( ) , ) ) ; }
Displays a form to edit an existing user entity.
Displays a form to edit an existing user entity .