Custom HTML Output on Zend Form Checkbox setLabel Property

那年仲夏 提交于 2019-12-23 17:00:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!