wenbert wrote:
> 
> I have this:
> <pre>
>       $elementDecorators = array(
>             'ViewHelper',
>             'Errors',
>             'Description',
>             array(array('data' => 'HtmlTag'), array('tag' => 'dd', 'class'
> => 'element')),
>             array('Label', array('tag' => 'dt'),
>             array(array('row' => 'HtmlTag'), array('tag' => 'dt')),
> 
>        ));
> 
>        $this->addElement('text', 'emp_lastname', array(
>             'decorators' => $this->elementDecorators,
>             'label'       => 'Employee Lastname:',
>             'required'   => true,
>             'attribs' =>   array(
>                                 'id'=>'emp_lastname',
>                                 'class'=>'normal_text_box'
>                             )
>         ));
> 
> IT OUTPUTS SOMETHING LIKE THIS:
> <dt>
> <label for="emp_lastname" class="required">Employee Lastname:</label>
> </dt>
> <dd class="element">
> <input type="text" name="emp_lastname" id="emp_lastname" value=""
> class="normal_text_box" />
> </dd> 
> </pre>
> 
> Can you explain me how the array $elementDecorator works? Especially the
> arrays after 'Description'...
> 
> Thanks so much!
> 
> Regards,
> Wenbert
> 

The way the decorators works is by parsing the options passed in the array
that is defined by them.

So the above example the decorator options array is being set to
'ViewHelper'  'Errors' and 'Description', you could set your own decorators
for each by using instead 
here is a small example to better explain this for you and get you started.

$this->setElementDecorators(array(
        'ViewHelper',

        array(
              array(
                    'inputOpen' => 'HtmlTag',
                    ),
              array('tag' => 'div',
                    'class' => 'formDataRight',
                    'openOnly' => true
                    ),
              'placement' => Zend_Form_Decorator_Abstract::PREPEND
              ),
        array('Description',
              array(
                    'placement' => array('inputClose', 'prepend'),
                    'tag' => 'div',
                    'class' => 'helpLine')
              ),
        array('Errors',
                array('tag' => 'div',
                      'placement' => 'prepend',
                      'class' => 'helpline'
                      )
            ),

-----
Nickolas Whiting 

Developer 

http://xstudiosinc.com Xstudios 
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-Decorators-explanation-tp20261370p20274012.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to