I'm having trouble removing the standard set of decorators using Zend_Form.
I am trying to extend Zend_Form to implement a different decorator style.
class CRM_Form extends Zend_Form
{
public function init()
{
$this->setDisableLoadDefaultDecorators(true);
$this->addDecorator('FormElements')
->addDecorator('Form');
$this->setElementDecorators(array(
'ViewHelper',
'Label',
'Errors',
new Zend_Form_Decorator_HtmlTag(array('tag' => 'p'))
));
}
}
When I try to use this class as follows:
$form = new CRM_Form();
$form->setAction('/')->setMethod('post');
$id = $form->createElement('text','id')->setLabel('ID:');
$form->addElement($id);
Old decorators are used (definition list), not my paragraph style.
If I add an Element () element to the init () method of the CRM_Form class, it uses the style I set.
How to force all elements created with this class to use my default style?
source
share