Question

I have the following element in Zend form:

$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. Any idea how I could make the HTML work in 'label' and 'description'.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top