2010-07-18 3 views
0

loadDefaultDecorators 함수로 데코레이터 label + HtmlTag를 제거하는 방법은 무엇입니까?Zend_Form - loadDefaultDecorators :: loadDefaultDecorators 함수를 사용하여 데코레이터를 제거하는 방법 label + HtmlTag?

내 솔루션 - 내 구현이 잘 작동하면 말해 또는 필요하세요 수정

class MyForm extend Zend_Form{ 

    function init(){ 
    //create form elements 
    ...................................... 
    } 

public function loadDefaultDecorators() { 
    if ($this->loadDefaultDecoratorsIsDisabled()) { 
    return $this; 
    } 
    foreach($this->getElements()as $elem){ 
    $elem->removeDecorator('Label') 
     ->removeDecorator('HtmlTag'); 
     } 
    return $this; 
    } 
} 

감사

답변

2
당신을 MyForm 클래스 loadDefaultDecorators 방법을 재정의했다,하지만 당신은 모든 요소에 대해 그렇게했다

수업. Form, FormElements 등의 폼 전용 데코레이터를 제공하지 않았기 때문에이 경우에는 HTML 코드가 표시되지 않습니다. 위에서 설명한 모든 데코레이터는 Zend_Form 클래스의 loadDefaultDecorators 메서드에 정의되어 있습니다. 당신의 loadDefaultDecorators 방법의 시작 부분에 다음 줄을 추가하십시오 :

parent::loadDefaultDecorators(); 

이것은 Zend_Form 클래스의 대응 방법을 호출합니다.

관련 문제