我想得到这样的东西:
<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中删除不需要的图例元素吗?
谢谢!
发布于 2013-07-15 13:18:10
您当然可以使用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>正如我在评论中所说的,由于您的代码不包括字段设置装饰器,我不知道您发布的内容怎么可能包含任何传说,所以在运行之后,您的应用程序中似乎有其他地方改变了装饰器。如果你仍然得到传奇,你需要尝试找出他们被添加到哪里。
https://stackoverflow.com/questions/17653291
复制相似问题