Hensembryan
Hensembryan

Reputation: 1087

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

Upvotes: 0

Views: 1583

Answers (1)

Michael Spector
Michael Spector

Reputation: 37009

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/

Upvotes: 2

Related Questions