Is it Possible to use HTML within a description decorator in a Zend_Form_Elment? For Example the following statement doesn't work:
$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'));
The link is not shown in the description, the brackets are converted into their special-char counterparts.
Is there another way to show a link (or use HTML at all...)?
It is possible, you just have to tell the Description
decorator not to escape output.
Try:
$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);
If you create your own set of decorators for elements, you can also specify this option when configuring decorators like this:
$elementDecorators = array(
'ViewHelper',
'Errors',
array('Description', array('class' => 'description', 'escape' => false)),
array('HtmlTag', array('class' => 'form-div')),
array('Label', array('class' => 'form-label', 'requiredSuffix' => '*'))
);
The relevant part being:
array('Description', array('class' => 'description', 'escape' => false)),