Override Separator on Zend_Form Radio Elements When Using a ViewScript Decorator

余生颓废 提交于 2019-12-04 19:39:30

In the view script, this line, $this->{$this->element->helper}(...), runs the functions listed in the Zend View Helpers documentation. The function in this case is formRadio(). There is a fifth parameter to formRadio() which is the separator! Adding the fifth parameter, by referencing the element, solves the problem:

<span class="value"><?php echo $this->{$this->element->helper}(
    $this->element->getName(),
    $this->element->getValue(),
    $this->element->getAttribs(),
    $this->element->getMultiOptions(),
    $this->element->getSeparator()
); ?></span>

I've had this problem, I've solved by using setting disableLoadDefaultDecorators to true and separator to &nbsp; or what ever you need.

$form->addElement('multiCheckbox', 'myFields', array(
    'disableLoadDefaultDecorators' => true
    ,'separator'    => '&nbsp;'
    ,'multiOptions' => array(
        'title'       => 'Title'
        ,'first_name' => 'First Name'
        ,'surname'    => 'Surname'
    )
    ,'decorators'   => array(
        'ViewHelper'
        ,'Errors'
        ,array('HtmlTag', array('tag' => 'p'))          
    )
));

Actually, it can be done in one line:

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