2013-06-05 3 views
3

에서 자신의 렌더링 나는 양식을 가지고 필드 중 하나입니다Symfony2 양식 : repated 유형과 나뭇 가지

$builder->add('password', 'repeated', array(
    'type' => 'password', 
    'invalid_message' => 'The password fields must match.', 
    'options' => array('attr' => array('class' => 'password-field')), 
    'required' => true, 
    'first_options' => array('label' => 'Password'), 
    'second_options' => array('label' => 'Confirm Password'), 
));   

모든 양식 렌더링을 제외하고, 여기 괜찮습니다. 나는 나뭇 가지 파일 형식이 방법을 렌더링하는 데 사용하고 있습니다 :

<table style="width:500px; padding:30px"> 
      <tr> 
       <td> 
        {{ form_label(form.email) }} 
       </td> 
       <td> 
        {{ form_widget(form.email, { 'attr': {'size': 30} }) }} 
       </td> 
      </tr> 
      <tr> 
       <td> 
        {{ form_label(form.password.first) }} 
       </td> 
       <td> 
        {{ form_row(form.password.first, { 'attr': {'size': 30} }) }} 
       </td> 
      </tr> 
      <tr> 
       <td> 
        {{ form_label(form.password.second) }} 
       </td> 
       <td> 
        {{ form_row(form.password.second, { 'attr': {'size': 30} }) }} 
       </td> 
      </tr> 
      <tr> 
.... 
.... 

문제는 repated 유형, 레이블이 중복된다는 점이다 : 첨부 된 이미지를 참조하십시오.

해결 방법을 알고 계십니까?

미리 감사드립니다. enter image description here

답변

5

form_widget() 대신 form_row()를 사용하여 암호 컨트롤을 출력 한 결과 레이블이 두 번 나타납니다. form_row() 메소드는 필드 오류, 레이블 및 위젯을 모두 한 번에 출력합니다. 필드 오류를 직접 출력하려면 예를 들어 다음을 사용할 수 있습니다. form_errors (form.password.first).

+0

완벽하게, 정말 고마워. –

관련 문제