2011-02-16 68 views
0

我正在設計一個項目的樣式,並且每個人都使用Zend_Form和默認元素。這使得樣式提交按鈕變得不可能。 因此,我想覆蓋提交按鈕的默認Zend_Form裝飾器,但沒有改變Zend_Form創建的每一行。覆蓋所有Zend_Form對象的特定裝飾器

這可能嗎? 如果是,如何?

回答

1

你可能想Zend_Form_Element_Submit和使用loadDefaultDecorators()設置缺省的裝飾爲您的提交:

class My_Form_Element_Submit extends Zend_Form_Element_Submit 
{ 
    public function loadDefaultDecorators() 
    { 
     // set your default decorators for the submit element  
     $decorators = $this->getDecorators(); 
     if (empty($decorators)) { 
      $this->setDecorators(array(
       'ViewHelper', 
       array(
        array('field' => 'HtmlTag'), 
        array(
         'tag' => 'span', 
         'class' => 'some-wrapper-class' 
        ) 
       ) 
      )); 
     } 
    } 
} 

上面裝飾將導致HTML代碼看起來像這樣,讓您輕鬆設計您的提交按鈕:

<span class="some-wrapper-class"> 
    <input type="submit" name="save" id="save" value="Save"> 
</span> 
+0

不,子類化完全不是我想要的。 – 2011-02-24 20:30:13