简体   繁体   English

在Zend表单元素上允许HTML

[英]Allow HTML on Zend form elements

I have the following element in Zend form: 我有以下Zend形式的元素:

$this->addElement('Select', 'my_element', array(
  'label' => 'My Element',
  'description' => 'My link <a href="https://www.google.com/">here</a>',
  'multiOptions' => array(
    'opt_one' => 'Option One',
    'opt_two' => 'Option Two',
  ),
));

I have also tried to add 'escape' => true, after 'multiOptions', but it does not take effect. 我还尝试在“ multiOptions”之后添加'escape' => true, ,但是它没有生效。 Any idea how I could make the HTML work in 'label' and 'description'. 我知道如何使HTML在“标签”和“描述”中起作用。

Try to do like this: 尝试这样做:

$select = new Zend_Form_Element_Select('my_element', array(
     'label' => 'My Element',
     'description' => 'My link <a href="https://www.google.com/">here</a>',
     'multiOptions' => array(
     'opt_one' => 'Option One',
     'opt_two' => 'Option Two'
)));

$select->getDecorator('Description')->setOption('escape', false);
$form->addElement($select);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM