Jakob Alexander Eichler
Jakob Alexander Eichler

Reputation: 3056

ZendFramework - How to wrap my label as well inside by my HtmlTag decorator's tag

I need to put some form elements in a table. I am having the issue, that my HtmlTag decorator wraps only my inputfield and not the label, even if I change the order of adding my decorators. The label is outstanding of the tag. Any suggestions?

                    $questionElement->addDecorators(array(
                    array( 'HtmlTag',   array( 'tag'=>'tr' ) ),
                    array( 'Label',     array( 'tag'=>'td' ) ),
                ));

Upvotes: 3

Views: 806

Answers (1)

ashurexm
ashurexm

Reputation: 6335

I just wrote a blog post about this the other day. For the purposes of styling I had the need to put an opening at the beginning of one element, and a closing tag at the end of another. The Zend Framework guides don't do a great job of detailing this.

On the element you want to add the opening div tag you would do the following:

$open_element->addDecorator(array(
    array('openDiv' =>'HtmlTag'),
    array('tag' => 'div', 'openOnly' => true)
));

On the second element, you'll want to add the closing tags:

$close_element->addDecorator(array(
    array('closeDiv' =>'HtmlTag'),
    array('tag' => 'div', 'closeOnly' => true)
));

Upvotes: 1

Related Questions