Zend 框架中的 DisplayGroup 装饰器 [英] DisplayGroup decorator in Zend Framework
问题描述
我正在使用 DisplayGroup 来呈现一组中的几个元素.现在我想做的是在单个表格行中呈现这个组.但事实证明,DisplayGroup 上的装饰器不的工作方式与它们在简单元素上的工作方式相同.一个例子:
I'm using DisplayGroup to render a couple of elements in a group. Now what I want to do, is render this group in a single table row. But it turns out, that Decorators on DisplayGroups do NOT work the same way they do on simple elements. An example:
$content = $this->getDisplayGroup('group');
$content->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'table', 'class' => 'element')),
));
这只是把
在我的 DisplayGroup 的末尾.我也试过给它们取别名:
This just puts
<table></table>
at the end of my DisplayGroup. I've also tried to alias them:
array(array('elementDiv' => 'HtmlTag'), array('tag' => 'table')),
'FormElements',
array(array('td' => 'HtmlTag'), array('tag' => 'table')),
仍然把它们放在一个地方,不是都试过 openOnly
和 closeOnly
:
Still puts them in one place, not both tried openOnly
and closeOnly
:
array(array('elementDiv' => 'HtmlTag'), array('tag' => 'table','openOnly'=>true)),
'FormElements',
array(array('td' => 'HtmlTag'), array('tag' => 'table','closeOnly'=>true)),
它仍然只放入结束标记.如果我将这些更改为 And it still puts in only the closing tag. If I change these to 所以,jah 是对的,没有添加的表确实是源代码查看器的错误. So, jah was right, and the table not being added was really a bug of source viewers. 这对我有用.不太确定描述装饰器的作用,但表格会根据需要呈现. This did the trick for me. Not really sure what the Description Decorator does, but the table renders as needed. 这篇关于Zend 框架中的 DisplayGroup 装饰器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!<td>
,一切正常,但对于 则不行,我错过了什么吗?
<td>
, everything works fine, but not with <table>
Am I missing something?推荐答案
$group->setDecorators(array(
'FormElements',
array('Description', array('escape' => false, 'tag' => false)),
array('HtmlTag', array('tag' => 'table', 'class' => 'element')),
));
登录
关闭