开发者

DisplayGroup decorator in Zend Framework

开发者 https://www.devze.com 2023-01-27 10:12 出处:网络
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

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 closeOn开发者_如何学Cly :

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号