Daniel Gadawski
Daniel Gadawski

Reputation: 1923

Setting HtmlTag decorator for form element

I'm learning how to use decorators in Zend Framework. I've go really simple code:

$this->addElement('text', 'wybor', array(
    'label' => 'Wybierz',
    'multiOptions' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
    'decorators' => array(
        'ViewHelper',
        'Errors',
        array('HtmlTag', array('tag' => 'td')),
    ),
));

but it seems that HtmlTag doesn't work in this case - form element isn't surrounded with tags.

Am I doing something wrong here? Thanks in advance for help.

Upvotes: 1

Views: 87

Answers (1)

Nasser Ghiasi
Nasser Ghiasi

Reputation: 372

you can use this code for more options:

$elementDecorators = array(
        'ViewHelper',
        array('Errors', array('class' => 'err-msg')),
        array(array('data' => 'HtmlTag'), array('tag' => 'span', 'class' => 'element')),
        array('Label', array('tag' => 'span')),
        array(array('row' => 'HtmlTag'), array('tag' => 'div','class'=>'form-row')),
    );

Upvotes: 1

Related Questions