2014-02-20 3 views
0

내 프로젝트에서 FOS 번들을 사용하고 있습니다. 내 관리자 번들에 새 컨트롤러 ChangePasswordController을 만들었습니다. 여기 내 코드가있다.symfony2에서 FOS 번들의 유효성 검사 메시지를 무시하는 방법

namespace Pondip\AdminBundle\Controller; 

use Symfony\Component\HttpFoundation\Request; 
use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Symfony\Component\HttpFoundation\RedirectResponse; 
use FOS\UserBundle\Controller\ChangePasswordController as BaseController; 

/** 

Controller managing the change password * 
@author Aman 
/
class ChangePasswordController extends BaseController 
{ 
/** 
This action is used for change password for admin. 
@author Aman 
@return render view 
@throws AccessDeniedException as exception 
@ 
*/ 
public function changePasswordAction() 
{ 
    $user = $this->container->get('security.context')->getToken()->getUser(); 


    $form = $this->container->get('fos_user.change_password.form'); 
    $formHandler = $this->container->get('fos_user.change_password.form.handler'); 

    $process = $formHandler->process($user); 
    if ($process) { 
     $this->setFlash('fos_user_success', 'Password has been changed successfully'); 

     $url = $this->container->get('router')->generate('pondip_admin_changepassword'); 
     return new RedirectResponse($url); 
    } 

    return $this->container->get('templating')->renderResponse(   
     'PondipAdminBundle:ChangePassword:changePassword.html.'.$this->container->getParameter('fos_user.template.engine'), 
     array('form' => $form->createView()) 
); 
} 

} 

이제 현재 비밀번호에 대한 오류 메시지를 맞춤화하고 싶습니다.

답변

1

FOSUserBundle을 재정의 하시겠습니까? Documentation을 참조하십시오. 그렇지 않다면 기본 동작을 수정하려면해야합니다.

자료/번역/validators.xx.yml :

그렇다면, 당신은 다음 FOSUserBundle 공급 업체에있는 FOSUserBundle, 번역 파일 (및 부모 디렉토리를) 재정의되는 번들에 복사해야 xx는 귀하의 지역입니다.

그런 다음 오류 메시지를 변경하십시오. 예를 들어 현재 비밀번호 오류를 변경하려면 다음을 작성하십시오.

fos_user: 
    [...] 
    current_password: 
     invalid: Your own error message here 
    [...] 

희망이 있습니다.