Im looking for a simple bit of code that will let me add the following html into my zend form:
Create a custom Decorator that return the label(or anything else):
class My_Decorator_CustomHtml extends Zend_Form_Decorator_Abstract {
public function render($content)
{
$element = $this->getElement();
if (!$element instanceof Zend_Form_Element) {
return $content;
}
if (null === $element->getView()) {
return $content;
}
$html = $element->getLabel();
return $html;
}
}
Place this in the decorator path
$form->addElementPrefixPath('My_Decorator',
'My/Decorator/',
'decorator');
Create the element and put the custom html in the label
$html = '';
$element = new Zend_Form_Element_Hidden('hidden-input', array(
'label'=>$html,
));
$element->setDecorators(array('CustomHtml'));
//add it to the form
$form->addElement($element);
and that's it