我想得到这样的东西:
<div class="widgetbox">
<legend class="widgettitle">Widget Box</legend>
<div class="widgetcontent"> Content goes here... </div>
</div>
我的代码看起来像这样:
$this->addDisplayGroup(
$fields,
'main',
array(
'legend' => $this->_tlabel.'group_main',
'decorators' => array(
'FormElements',
array(
array('widgetcontent'=>'HtmlTag'), array('tag'=>'div', 'class'=>'widgetcontent')
),
array('HtmlTag',array('tag' => 'div', 'class' => 'widgetbox')),
)
)
);
我所能得到的只是:
<div class="widgetbox">
<legend>Main info</legend>
<div class="widgetcontent">
<legend>Main info</legend>
</div>
</div>
正如您所看到的,我获得了双图例元素,但我只想要一个 - 首先,在 div.widgetbox 之后。
你能帮我从嵌套div中删除不需要的图例元素吗?
谢谢!
答案 0 :(得分:2)
您当然可以使用h4
,而不是传说。尝试:
$this->addDisplayGroup(
$fields,
'main',
array(
'description' => 'Widget title',
'decorators' => array(
'FormElements',
array(array('widgetcontent' => 'HtmlTag'), array('tag'=>'div', 'class'=>'widgetcontent')),
array('Description', array('tag' => 'h4', 'placement' => 'prepend', 'class' => 'widgettitle')),
array(array('widgetbox' => 'HtmlTag'), array('tag' => 'div', 'class' => 'widgetbox'))
)
)
);
这会添加描述装饰器并将其标记设置为<h4>
。我也使用widgetbox装饰器别名,以便更清楚地将它们组合在一起。这给了我:
<div class="widgetbox">
<h4 class="widgettitle">Widget title</h4>
<div class="widgetcontent">...</div>
</div>
正如我在评论中所说,由于您的代码不包含字段集装饰器,我看不出您发布的内容可能包含任何图例,所以看起来您的应用中有其他内容在此运行后更改装饰器。如果你还在传说中,你需要尝试找出它们的添加位置。