DisplayGroup decorator in Zend Framework

别说谁变了你拦得住时间么 提交于 2019-12-10 11:59:01

问题


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

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

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 <td>, everything works fine, but not with <table> Am I missing something?


回答1:


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.



来源:https://stackoverflow.com/questions/4315967/displaygroup-decorator-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!