2010-05-13 57 views
2

我試圖生成我的Zend_Form顯示組這個網站層次:如何使用裝飾器將多個div或fieldset添加到zend_form中?

<div class="settings"> 
    <div class="dashed-outline"> //want to add this div 
     <fieldset disabledefaultdecorators="1" id="fieldset-settings"> 
      <legend>Cards</legend> 
      </fieldset> 
     </div>  
    </div> 

這是我目前:

<div class="settings"> 
     <fieldset disabledefaultdecorators="1" id="fieldset-settings"> 
      <legend>Cards</legend> 
      </fieldset> 
    </div> 

這是上面的代碼:

$form->addDisplayGroup($flashcardGroup, 
          'settings', 
          array(
           'legend' => 'Cards', 
           'disableDefaultDecorators' => true, 
           'decorators' => array(
                'FormElements', 
                'Fieldset', 
                array('HtmlTag',array('tag' => 'div', 'class' => 'settings')), 
                ) 
           ) 
          ); 

如何在這裏添加額外的div?

回答

6

如果您想在Zend_Form中使用相同的裝飾器兩次,則可以使用setDecorators數組語法傳遞array(array('alias'=>'Decorator'), $options)。此外,你應該不需要使用disableDefaultDecorators如果你傳遞一個decorators選項

$form->addDisplayGroup($flashcardGroup, 
    'settings', 
    array(
    'legend' => 'Cards', 
    'decorators' => array(
     'FormElements', 
     'Fieldset', 
     // need to alias the HtmlTag decorator so you can use it twice 
     array(array('Dashed'=>'HtmlTag'), array('tag'=>'div', 'class'=>'dashed-outline')), 
     array('HtmlTag',array('tag' => 'div', 'class' => 'settings')), 
    ) 
) 
); 
+0

感謝,稍加調整,即工作。 – 2010-05-13 21:07:19

相關問題