Skip to content

Zend Framework: Add HTML to form element label

Aug 21, 2012 1 min read #zend-framework

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against 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);
php

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