How to write html in a form element's label

For programming and general questions on Zend Framework

How to write html in a form element's label

Postby scilingir on Tue Mar 09, 2010 6:29 pm

Hi people,

I have a small question about Zend Forms and if you could help, I'd appreciate it.
I want to be able to write html in an element label. (For ex. just an anchor)
You have any idea how to do that?

Thanks in advance.
scilingir
 
Posts: 2
Joined: Tue Mar 09, 2010 6:28 pm

Re: How to write html in a form element's label

Postby scilingir on Tue Mar 09, 2010 6:46 pm

ok nevermind, got it myself. But just so you need it, you can add the parameter 'escape' => false to your label decorator.
scilingir
 
Posts: 2
Joined: Tue Mar 09, 2010 6:28 pm

Re: How to write html in a form element's label

Postby premchand on Wed Mar 10, 2010 10:00 am

When setting label as decorator for some of your element, supply option "escape" parametar, with false value, for example:

[$yourElement->addDecorator('Label', аrray('escape'=>false));]

Then you can put some HTML in your label and tags won't be escaped.
premchand
 
Posts: 1
Joined: Wed Mar 10, 2010 9:56 am

Re: How to write html in a form element's label

Postby stevesand on Thu Apr 28, 2011 4:36 pm

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

Will not mess up the ordering of your decorators or effect the other label's properties.
stevesand
 
Posts: 1
Joined: Thu Apr 28, 2011 4:29 pm

Re: How to write html in a form element's label

Postby cherch on Tue Jul 03, 2012 12:31 am

hi please help me
I use thsis code to create an element
$element = new Zend_Form_Element_Checkbox('Agree', array(
'label' => 'I have read and agree with the <br/>contest rules and regulations.',
'filters' => array('StringTrim', 'StripTags')
));

how to set escape=false now
cherch
 
Posts: 1
Joined: Tue Jul 03, 2012 12:30 am


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 13 guests