views:

339

answers:

2

I want to include some HTML in the labels of the radio buttons so that the user can click a link within that label. For example

<label for="value-12">
    <input name="value" id="value-12" value="12" checked="checked" type="radio">
    Doo Bee Dooo Bee Doooo
    <a href="somelink">preview this song</a>
</label>

The html keeps getting escaped. I want to stop that. I read about:

array('escape' => false)

Somewhere, but I don't know how to use that with

$value->setMultiOptions($songs);

or

$value->addMultiOptions($songs)

Any ideas? Thanks all!

EDIT

While setting escape to false for the "Label" decorator may work, this is not exactly what I want to do. I want to set escape to false for the labels of the multioptions. The following is not what I want to do. See the HTML I added in the setMultiOptions? That's what I want to escape:

    $value = new Zend_Form_Element_Radio('value');
    $value->setMultiOptions(array('NULL'=>'None <a href="#">A Link</a>'));
    $value->addMultiOptions($this->objlist);
    $value->setLabel($this->title);
    $value->getDecorator('Label')->setOption('escape', false);
A: 

Put it into decorators ;) you need to set that to the Label decorator ;)

$el->getDecorator('Label')->setOption('escape', false);

(not sure about concrete method names, but you get the point)

Tomáš Fejfar
Please see my edit. I want to escape the labels for the elements added with setMultiOptions or addMultiOptions. Though I did originally mention it, sorry if it was not clear enough.
sims
+2  A: 

And the answer is:

$value = new Zend_Form_Element_Radio('value', array('escape'=>false));

Thanks to alokin at:

http://forums.zend.com/viewtopic.php?f=69&amp;t=5938&amp;start=0&amp;sid=987612aa8ff8193a04bf73a52196358b

sims
Ha, nice. This didn't work in previous versions ;)
Tomáš Fejfar
I'm going to try to have it added to the docs - if it really is a feature and not some undocumented leftover.
sims