如何使用Zend Form Decorator将所有输入和标签放入div?

My code looks like:

$this->setElementDecorators(array(
   array('ViewHelper'),
   array('Errors', array('tag' => 'div', 'class' => 'error')),
   array('Label', array('tag' => 'span')),
   array('HtmlTag', array('tag' => 'div'))
));

And it gives me:

<div>
   <div id="email-label"><label for="email" class="required">First name:</label></div>
   <input type="text" name="email" id="email" value="" />
</div>
<div>
   <div id="email-label"><label for="email" class="required">Last name:</label></div>
   <input type="text" name="email" id="email" value="" />
</div>

But I would like to have everything in divs with specified classes, like this:

<div class="item">
   <div class="label"><label for="email" class="required">First name:</label></div>
   <div class="element"><input type="text" name="email" id="email" value="" /></div>
</div>
<div class="item">
   <div class="label"><label for="email" class="required">Last name:</label></div>
   <div class="element"><input type="text" name="email" id="email" value="" /></div>
</div>

How can I do this? I read the manual, but I don't have more ideas :(

Try:

$this->setElementDecorators(array(
   array('ViewHelper'),
   array('Errors', array('tag' => 'div', 'class' => 'error')),
   array('Label', array('tag' => 'span')),
   array('HtmlTag', array('tag' => 'div', 'class' => 'label')),
));

And then when you render your form, manually render it like this:

<div class="form">
    <form method="<?php echo $this->form->getMethod() ?>"
          action="<?php echo $this->form->getAction() ?>">

        <div class="item">
            <?php echo $this->form->firstName ?></div>
        </div>

        <div class="item">
            <?php echo $this->form->lastName ?></div>
        </div>

        // the rest of your elements...

        <?php echo $this->form->submit ?>
    </form>
</div>

Outputting individual form elements in your view gives you more control over the output of the form and gives you much greater control of where the elements appear and the HTML that they are wrapped within.

When I can, I will use the short <?php echo $this->form ?> but most of my forms are fancier and I use custom markup in conjunction with my element decorators to get the form to look exactly how I want.

See also Using ViewScript Decorator on Nested Subforms (Zend Form) and How To Remove All DtDdWrappers and Labels on Zend Form Elements.