问题
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);
来源:https://stackoverflow.com/questions/2711650/custom-html-output-on-zend-form-checkbox-setlabel-property