是否可以在 Zend_Form_Elment 的描述装饰器中使用 HTML?例如,以下语句不起作用:
$number = new Zend_Form_Element_Text('number', array(
'size' => 32,
'description' => 'Please the the following website: <a href="foo/bar">lorem ipsum</a>',
'max_length' => 100,
'label' => 'Number'));
描述中未显示链接,括号将转换为其特殊字符对应项。
是否有其他方法来显示链接(或根本使用 HTML...)?
最佳答案
这是可能的,您只需告诉 Description
装饰器不要转义输出即可。
尝试:
$number = new Zend_Form_Element_Text('number', array(
'size' => 32,
'description' => 'Please the the following website: <a href="foo/bar">lorem ipsum</a>',
'max_length' => 100,
'label' => 'Number')
);
$number->getDecorator('Description')->setOption('escape', false);
如果您为元素创建自己的一组装饰器,则也可以在配置装饰器时指定此选项,如下所示:
$elementDecorators = array(
'ViewHelper',
'Errors',
array('Description', array('class' => 'description', 'escape' => false)),
array('HtmlTag', array('class' => 'form-div')),
array('Label', array('class' => 'form-label', 'requiredSuffix' => '*'))
);
相关部分是:
array('Description', array('class' => 'description', 'escape' => false)),
关于zend-framework - 在 Zend_Form_Element 描述装饰器中使用 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11415659/