$text = new Zend_Form_Element_Text('name'); $text->setLabel('Enter your name:') ->setRequired(true) ->addFilter('StripTags') ->addValidator('NotEmpty') ->setDecorators(array( 'ViewHelper', 'Description', 'Errors', array('Label', array('class' => 'label')), array('HtmlTag', array('class' => 'field')), )); $decorators = $text->getDecorator('Label');
$form = new Zend_Form(); $form->addElement('text', 'name', array( 'label' => 'Enter your name:', 'decorators' => array( array('ViewHelper'), array('Errors'), array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'field')), ), )); $nameElement = $form->getElement('name'); $decorators = $nameElement->getDecorator('HtmlTag');In this example, we're creating a new form and adding a text input element to it with a label and decorators. We then retrieve the element using getElement() and use getDecorator() to retrieve the 'HtmlTag' decorator. These examples demonstrate the use of getDecorator() with Zend_Form_Element_Text to retrieve decorators associated with the element. The Zend_Form_Element_Text class is part of the Zend_Form package library.