Custom HTML Output on Zend Form Checkbox setLabel

2019-07-03 17:43发布

问题:

I am rendering a Zend Form Checkbox and I would like to render some custom html at its setlabel property.

My form construct model

$terms = new Zend_Form_Element_Checkbox('confirm_terms');

In my View Script

$this->form->confirm_terms->setLabel('<a href="'.'/index/terms'.'">Terms of Service</a>');

However since setLabel escapes the output it rendered as it is.

Any creative ways of rendering the setlabel property as CustomHTML?

回答1:

You need to disable the auto-escaping of the label, following your example, you would use this code:

$this->form->confirm_terms->getDecorator('Label')->setOption('escape', false);