2012-07-10 35 views
2

是否有可能在Zend_Form_Elment的描述装饰器中使用HTML?例如,下面的语句不起作用:在Zend_Form_Element描述装饰器中使用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的所有...)的方法?

回答

4

这是可能的,你只需告诉Description装饰者不要逃避输出。

尝试:

$elementDecorators = array(
     'ViewHelper', 
     'Errors', 
     array('Description', array('class' => 'description', 'escape' => false)), 
     array('HtmlTag',  array('class' => 'form-div')), 
     array('Label',  array('class' => 'form-label', 'requiredSuffix' => '*')) 
); 

相关的部分是:

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

如果你创建自己的元素集装饰的,你也可以配置装饰这样,当指定了此选项

array('Description',array('class'=>'description','escape'=> false)),