Zend Form复选框setLabel属性上的自定义HTML输出 [英] Custom HTML Output on Zend Form Checkbox setLabel Property

查看:43
本文介绍了Zend Form复选框setLabel属性上的自定义HTML输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在渲染一个Zend表单复选框,我想在其setlabel属性中渲染一些自定义html.

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

我的表单构造模型

$terms = new Zend_Form_Element_Checkbox('confirm_terms');

在我的查看脚本中

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

但是,由于setLabel对输出进行了转义,因此它按原样呈现.

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

有什么创造性的方法可以将setlabel属性呈现为CustomHTML?

Any creative ways of rendering the setlabel property as CustomHTML?

推荐答案

您需要禁用标签的自动转义,按照您的示例,您将使用以下代码:

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);

这篇关于Zend Form复选框setLabel属性上的自定义HTML输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆