Zend_Form_Element_Radio MultiOptions do not escape label

For programming and general questions on Zend Framework

Zend_Form_Element_Radio MultiOptions do not escape label

Postby _sims_ on Sun Mar 28, 2010 2:53 am

Hi all,

This is my first post. So please tell me if this is the wrong place for this. Thanks.

I've the following code:

Code: Select all
    $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);


Obviously this does not work. The getDecorator('Label') gets the decorator for the label which comes before all the real radio elements and identifies this group of radio elements. That's not what I want. What I want to do is: disable escaping for the labels for all the radio elements added with setMultiOptions and/or addMultiOptions.

Any ideas? Thanks!
_sims_
 
Posts: 18
Joined: Sun Mar 28, 2010 2:44 am

Re: Zend_Form_Element_Radio MultiOptions do not escape label

Postby alokin on Sun Mar 28, 2010 9:44 am

Try to instantiate your radio element this way:
Code: Select all
$value = new Zend_Form_Element_Radio('value', array('escape'=>false));

Notice that "escape" attrib in that array which is passed as second argument.
alokin
 
Posts: 75
Joined: Thu Mar 04, 2010 9:04 pm

Re: Zend_Form_Element_Radio MultiOptions do not escape label

Postby _sims_ on Mon Mar 29, 2010 12:40 am

Fantastic!!! That's right on! It works. You have no idea how long I've been searching for the answer to this. I was almost going to make a form manually. Did I miss this in the docs somewhere?
_sims_
 
Posts: 18
Joined: Sun Mar 28, 2010 2:44 am

Re: Zend_Form_Element_Radio MultiOptions do not escape label

Postby alokin on Mon Mar 29, 2010 10:03 am

No, I think that it isn't mentioned in manual, but all you have to do is just a little code examination of the objective class. That's how I found the solution for your demand. :)
alokin
 
Posts: 75
Joined: Thu Mar 04, 2010 9:04 pm

Re: Zend_Form_Element_Radio MultiOptions do not escape label

Postby _sims_ on Tue Mar 30, 2010 9:09 am

Thanks alokin!

In this case what would I be looking for in the source code? Should I grep for "escape"? Is it a smart idea to look at the constructor? I like manuals, but I think I should try looking in the source too. So I'd like to have some pointers.
_sims_
 
Posts: 18
Joined: Sun Mar 28, 2010 2:44 am

Re: Zend_Form_Element_Radio MultiOptions do not escape label

Postby alokin on Tue Mar 30, 2010 9:41 am

If you are asking me to tell you about the place in code from which I've realized that preventing of escaping is possible, then it is part between 138. and 140. line in Zend_View_Helper_FormRadio class (ZF v1.10). And that $escape variable is available as a result of extract() function call (line 76), which extracts info gathered from _getInfo() method, which prepares all supplied params ($name, $value, $attribs, $options, $listsep).
alokin
 
Posts: 75
Joined: Thu Mar 04, 2010 9:04 pm


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 11 guests