2009-12-03 49 views
1

我需要装点Zend_Form_Element_MultiCheckbox成无序列表装潢Zend_Form_Element_MultiCheckbox,我可以<li>得到每个项目环绕,通过设置setSeparator到</li><li>和HtmlTag标签<li>在一个无序列表

我只是得到找到任何围绕此列表设置<ul>,任何人都能指出我正确的方向?

感谢您阅读(我的代码如下所示)

$interests = new Zend_Form_Element_MultiCheckbox('foo'); 
    $interests->setSeparator('</li><li>'); 

    foreach ($interestsTable->findForSelect() as $interest) { // For earch interest add an option 
     $interests->addMultiOption($interest->interest_id, $interest->interest); 
    } 

    // Decorate the interests 
    $interests->setDecorators(array(
    array('ViewHelper'), 
    array('label', array(
    'tag' => 'span' )), 
    array('HtmlTag', array(
    'tag' => 'li', 'class' => 'interestOption')) 
)); 

回答

1

我不能给你任何代码,将工作过我的头顶,但是,从阅读的文档,很明显,你可以根据需要多次重复使用装饰器。你只需要为他们指定一个新的名字。

请看:http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.decorators,特别是标题为“使用同一类型的多个装饰器”的部分。

此基础上,下面可能工作(但我没有测试它,它可能是错误的顺序或任何东西):

$interests->setDecorators(
    array(
     array('ViewHelper'), 
     array('label', array('tag' => 'span')), 
     array('HtmlTag', array('tag' => 'li', 'class' => 'interestOption')), 
     array(
      'decorator' => array('LiTag' => 'HtmlTag'), 
      'options' => array('tag' => 'ul') 
     ) 
    ) 
); 
+0

感谢奏效一种享受 - 我得到的是什么回事也是 – Timmeh 2009-12-04 11:15:15

相关问题