简体   繁体   中英

How to prevent escaping on Zend Form Select : Zend Framework

how to prevent escaping html on zend form elemnt? My code is not work at all

$this->addElement('Select', 'forum_icon', array(
        'label' => 'Forum Icon',
        'value' => $this->_forum->FORUM_ICON,
        'escape' => false,
        'multiOptions' => $icons
    ));

i try another method but it still not work

$this->forum_icon->setAttrib('escape', false);

thanks in advance,

Brian

You can implement your decorator for Select element that generates HTML for select with unescaped value. For example:

class My_Select_Decorator extends Zend_Form_Decorator_Abstract
{
    public function render($content)
    {
        $element = $this->getElement();
        // Generate HTML markup
        return $markup;
    }
}

Refer to these articles for more information:

http://weierophinney.net/matthew/archives/212-The-simplest-Zend_Form-decorator.html

http://codeutopia.net/blog/2008/08/07/zend_form-decorator-tips/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM