Zend 框架中的 DisplayGroup 装饰器 [英] DisplayGroup decorator in Zend Framework

查看:23
本文介绍了Zend 框架中的 DisplayGroup 装饰器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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')),

仍然把它们放在一个地方,不是都试过 openOnlycloseOnly :

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)),

它仍然只放入结束标记.如果我将这些更改为 <td>,一切正常,但对于

则不行,我错过了什么吗?

And it still puts in only the closing tag. If I change these to <td>, everything works fine, but not with <table> Am I missing something?

推荐答案

所以,jah 是对的,没有添加的表确实是源代码查看器的错误.

So, jah was right, and the table not being added was really a bug of source viewers.

$group->setDecorators(array(

            'FormElements',
        array('Description', array('escape' => false, 'tag' => false)),
        array('HtmlTag', array('tag' => 'table', 'class' => 'element')),
));

这对我有用.不太确定描述装饰器的作用,但表格会根据需要呈现.

This did the trick for me. Not really sure what the Description Decorator does, but the table renders as needed.

这篇关于Zend 框架中的 DisplayGroup 装饰器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆