public function editProfileAction()
    {
        if(!$user = $this->identity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        
        $form = $this->getUserFormHelper()->createUserForm($user, 'EditProfile');
        $email = $user->getEmail();
        $username = $user->getUsername();
        $message = null;    
        if($this->getRequest()->isPost()) {
            $currentFirstName = $user->getFirstName();
            $currentLastName = $user->getLastName();
            $form->setValidationGroup('firstName', 'lastName', 'language', 'csrf');
            $form->setData($this->getRequest()->getPost());
            if($form->isValid()) {
                $firstName = $this->params()->fromPost('firstName');
                $lastName = $this->params()->fromPost('lastName');
                $user->setFirstName($firstName);
                $user->setLastName($lastName);    
                $entityManager = $this->getEntityManager();
                $entityManager->persist($user);
                $entityManager->flush();    
                $message =  $this->getTranslatorHelper()->translate('Your profile has been edited');
            }
        }
    
        return new ViewModel(array(
            'form' => $form,
            'email' => $email,
            'username' => $username,
            'securityQuestion' => $user->getQuestion()->getQuestion(),
            'message' => $message,
            'navMenu' => $this->getOptions()->getNavMenu()
        ));
    }
public function editProfileAction()
    {
        if(!$user = $this->identity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
        
        $form = $this->getUserFormHelper()->createUserForm($user, 'EditProfile');
        $email = $user->getEmail();
        $username = $user->getUsername();
        $message = null;    
        if($this->getRequest()->isPost()) {
            $currentFirstName = $user->getFirstName();
            $currentLastName = $user->getLastName();
            $form->setValidationGroup('firstName', 'lastName', 'language', 'csrf');
            $form->setData($this->getRequest()->getPost());
            if($form->isValid()) {
                $firstName = $this->params()->fromPost('firstName');
                $lastName = $this->params()->fromPost('lastName');
                $user->setFirstName($firstName);
                $user->setLastName($lastName);    
                $entityManager = $this->getEntityManager();
                $entityManager->persist($user);
                $entityManager->flush();    
                $message =  $this->getTranslatorHelper()->translate('Your profile has been edited');
            }
        }
    
        return new ViewModel(array(
            'form' => $form,
            'email' => $email,
            'username' => $username,
            'securityQuestion' => $user->getQuestion()->getQuestion(),
            'message' => $message,
            'navMenu' => $this->getOptions()->getNavMenu()
        ));
    }
public function editProfileAction ( ) { if ( ! $ user = $ this -> identity ( ) ) { return $ this -> redirect ( ) -> toRoute ( $ this -> getOptions ( ) -> getLoginRedirectRoute ( ) ) ; } $ form = $ this -> getUserFormHelper ( ) -> createUserForm ( $ user , 'EditProfile' ) ; $ email = $ user -> getEmail ( ) ; $ username = $ user -> getUsername ( ) ; $ message = null ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ currentFirstName = $ user -> getFirstName ( ) ; $ currentLastName = $ user -> getLastName ( ) ; $ form -> setValidationGroup ( 'firstName' , 'lastName' , 'language' , 'csrf' ) ; $ form -> setData ( $ this -> getRequest ( ) -> getPost ( ) ) ; if ( $ form -> isValid ( ) ) { $ firstName = $ this -> params ( ) -> fromPost ( 'firstName' ) ; $ lastName = $ this -> params ( ) -> fromPost ( 'lastName' ) ; $ user -> setFirstName ( $ firstName ) ; $ user -> setLastName ( $ lastName ) ; $ entityManager = $ this -> getEntityManager ( ) ; $ entityManager -> persist ( $ user ) ; $ entityManager -> flush ( ) ; $ message = $ this -> getTranslatorHelper ( ) -> translate ( 'Your profile has been edited' ) ; } } return new ViewModel ( array ( 'form' => $ form , 'email' => $ email , 'username' => $ username , 'securityQuestion' => $ user -> getQuestion ( ) -> getQuestion ( ) , 'message' => $ message , 'navMenu' => $ this -> getOptions ( ) -> getNavMenu ( ) ) ) ; }
Edit Profile Action

Displays user edit profile form

@return Zend\View\Model\ViewModel
Edit Profile Action