2013-01-31 2 views
0

기존 양식에 동의 체크 박스를 추가하고 있습니다. 확인란의 오른쪽에 레이블을 렌더링 할 수 없습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?요소의 오른쪽에 레이블을 어떻게 렌더링 할 수 있습니까?

양식의 나머지 부분이 이렇게 작성되었으므로 $this->addElement(을 사용하여 확인란을 만들었습니다.

미리 감사드립니다.

$this->addElement('checkbox', 'isUserConsent', array(
     'options' => array(array('placement' => 'APPEND')), 
     'label' => 'Plz activate', 
     'validators' => array(
      array('InArray', false, array(
       'hay' => array(1), 
       'messages' => 'Please check the consent box'), 
      ) 
     ), 
     'decorators' => array('ViewHelper','Errors','Label'), 
)); 

답변

2

기본값은 라벨을 앞에 추가하는 것입니다,하지만 당신은 장식의 '위치'옵션을 수정하여 변경할 수 있습니다 :

$this->getElement('isUserConsent')->getDecorator('label')->setOption('placement', 'append'); 

편집 : 나는 장식이 구문을 사용하지 않습니다하지만해야 다음과 같이하십시오 :

$this->addElement('checkbox', 'isUserConsent', array(
     'options' => array(array('placement' => 'APPEND')), 
     'label' => 'Plz activate', 
     'validators' => array(
      array('InArray', false, array(
       'hay' => array(1), 
       'messages' => 'Please check the consent box'), 
      ) 
     ), 
     'decorators' => array(
      'ViewHelper', 
      'Errors', 
      'Label' => array(
       'placement' => 'append' 
      ) 
     ), 
)); 
+0

나는 이것을 시도 할 것이다. 하지만 addElement 메소드 내부에서이를 설정할 수있는 방법이 있습니까? – ryy

+0

예를 들어 답을 편집했습니다. 그러나 그것이 작동하지 않는 경우 알려주지. –

+0

'decorators'=> array (array ('Label', 배열 ('placement'=> 'APPEND')))); 포인터 고마워. – ryy

0

이것은 양식 요소의 lable을 렌더링하기위한 코드입니다.

$ this-> form-> name-> renderLabel();