-- Bruno Friedmann <[EMAIL PROTECTED]> wrote
(on Tuesday, 26 August 2008, 09:50 AM +0200):
> Hi All, I have to ask for this because not found anything in archives nor 
> Google or Yahoo.
> 
> I need to have a label ( for a select element in Zend_Form )
> this label must contain a link like this
> 
> <a href="#" onclick="javascript: alert('thing');">More</a>
> 
> 
> $mylink = '<a href="#" onclick="javascript: alert('thing');">More</a>';
>       
> $element = new Zend_Form_Element_Select('partnerid');
> $element->addMultiOptions($this->partners_array)
>         ->setRequired(true)
>         ->setLabel( 'this is normal text' . $mylink )
>         ->setAttrib('size', 1)
>         ->setAttrib('maxlength', 1)
>         ->setAttrib('onclick', 'javascript: ShowPartnerDetails(); return 
> false;')
>         ->addFilter($filterTags)
>         ->addFilter($filterTrim)
>         ->addValidator($validatorNotEmpty, true)
>         ->addValidator($validatorNum, true)
>         ->setValue(1)
>         ;
> $this->addElement($element);
> 
> Of course like this it's render with htmlentities ( did I mention I hate it 
> :-)
> 
> I couldn't be able to find how to make this or which method & options I've to 
> call.
> 
> Has someone a way ?

After you've setup the element, grab the label decorator:

    $decorator = $element->getDecorator('Label');

and then tell it not to escape:

    $decorator->setOption('escape', false);

Alternately, you can do this at configuration time when setting up the
decorator -- add an additional 'escape' option to pass to it.

And that's all there is to it.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to