Zend Framework: Add HTML to form element label

Aug 21, 2012 zend-framework
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

By default, the labels of form elements in Zend Form are escaped. Sometimes, like in check mark boxes for Terms of Use, it makes sense to add some HTML to this. You can turn off escaping - but just be careful!

Example:

$this->getElement('agreetos')->getDecorator('Label')->setOption('escape', false);

So, there you go - you can now add a link to that label.

Go to All Posts