コード例 #1
0
ファイル: IndexController.php プロジェクト: neotok/front
	 /**
	  * Enter description here ...
	  */
	 public function editAction()
	 {
	 	$id 			= (int) $this->getRequest()->getParam('id');
	  	$userService 	= new User_Service_User();
	  	$user			= $userService->read( $id );
	  	if( !$user instanceof User_Model_User){
	  		$this->addSystemError('L\'utilisateur n\'existe pas');
	  		$this->_redirect( '/User/index/list');
	  	}
	  	$form 			= new User_Form_Edituser();
	  	$form->setAction( '/User/index/edit/id/' . $id);
	 	if( $this->getRequest()->isPost() ){
	 		if( $form->isValid( $this->getRequest()->getPost() ) ){
				if( $userService->update( $id, $form->getValues() )){
					$this->addSystemSuccess('Utilisateur mis à jour');
				} else {
					$this->addSystemError('Echec de la mise à jour');
				}
	 		} else {
	 			$this->addSystemError('Le formulaire contient des erreurs');
	 		}
	 	} else {
			$userData 		= array( 'login' => $user->getLogin(),
									 'nom' => $user->getNom(),
									 'prenom' => $user->getPrenom(),
									 'email' => $user->getEmail(),
									 'telephone' => $user->geTtelephone(),
									 'civilite' => $user->getcivilite() 
									);
			$form->populate( $userData );
	 	}
		$this->view->form = $form;
	 }