views:

133

answers:

1

Hi,

I'm trying to change the html outputted by Zend_Form using decorators.

I want the outputted HTML to look like this:

<form>
    <fieldset>
    <legend>Your Details</legend>
    <dl>
    <dt>label etc</dt>
    <dd>input etc</dd>
    <dt>label etc</dt>
    <dd>input etc</dd>
    </dl>
    </fieldset>
    <fieldset>
    <legend>Address Details</legend>
    <dl>
    <dt>label etc</dt>
    <dd>input etc</dd>
    <dt>label etc</dt>
    <dd>input etc</dd>
    ... etc ...
    </dl>
    </fieldset>
</form>

I've already broken the sections down i want within specific fieldsets using display groups, e.g.

$this->addDisplayGroup(array('name','email','telephone'),'yourdetails');
$yourdetails= $this->getDisplayGroup('personal');
$yourdetails->setDecorators(array(
            'FormElements',
            'Fieldset'
));

This gives me each section sitting within a fieldset but each form element is now lacking a wrapping dl so what i have is:

<form>
    <fieldset>
    <dt>label etc</dt>
    <dd>input etc</dd>
    <dt>label etc</dt>
    <dd>input etc</dd>
    </fieldset>
    ... etc
</form>
+1  A: 

Try this:

$yourdetails->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'dl')),
            'Fieldset'
));

That should:

  1. Iterate through the elements
  2. Add a <dl> around the group of elements
  3. Add a <fieldset> around the <dl>
Johrn
indeed it does! thanks a lot :)
seengee