我正在尝试在zend_form显示组中生成此html层次结构:
<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?
答案 0 :(得分:6)
如果要在Zend_Form中两次使用相同的装饰器,可以使用array(array('alias'=>'Decorator'), $options)
数组语法传递setDecorators
。此外,如果您传递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')),
)
)
);