I'm not totally understanding of how the decorators work, so it took some
fiddling to figure it out. It's similar to if you wanted to change to a
table layout, you wanted a dl to wrap the elements, similar to a tr that
that wraps the elements.
Try adding this to your elements.
$element->addDecorators(array(
array(array('row'=>'HtmlTag'),array('tag'=>'dl2'))
));
I changed line 7 to 'array('separator' => "\n"),' - the separator was
giving you the "extra" dl. Couldn't remove it as then none of the elements
would show up.
I mis-taged the dl's on purpose "dl2" and "dl6" so that I could see where
they eneded up.
3 $subForm->setDecorators(
4 array(
5 array(
6 array('myFormElements' => 'FormElements'),
7 array('separator' => "\n"),
8 ),
9 array(
10 array('myDlTag' => 'HtmlTag'),
11 array('tag' => 'dl6')
12 ),
13 'Form',
14 'Fieldset',
15 )
16 );
Resulting form is :
I only added the code to the one form element, which is why the submit
button doesn't have the dl2 tag.
---
<fieldset id="testform">
<form id="testform" enctype="application/x-www-form-urlencoded"
action="/testform method="post">
<dl6>
<dl2>
<dt id="ncode-label"><label for="ncode" class="required">Enter
code</label></dt>
<dd id="ncode-element">
<input type="text" name="ncode" id="ncode" value="" maxlength="125"
class="frmImput" size="32"></dd>
</dl2>
<dt id="submitBTN-label"> </dt><dd id="submitBTN-element">
<input type="submit" name="submitBTN" id="submitBTN" value="Update"></dd>
</dl6>
</form>
</fieldset>
---
Hope that helps
Terre
-----Original Message-----
From: Mike Wright [mailto:[email protected]]
Sent: Saturday, November 05, 2011 12:25 PM
To: Zend Framework
Subject: [fw-general] [repost] how to wrap an element in a dl?
Hi all,
Posted yesterday @12:54 pm pdt but the message seems to have gone astray...
Default decorators are <dt> for the labels and <dd> for the form elements.
I would like to wrap each of the <dt/><dd/> in a <dl>.
I've done this:
1 (Zend_Form_SubForm $subForm)
2
3 $subForm->setDecorators(
4 array(
5 array(
6 array('myFormElements' => 'FormElements'),
7 array('separator' => "</dl>\n<dl>"),
8 ),
9 array(
10 array('myDlTag' => 'HtmlTag'),
11 array('tag' => 'dl')
12 ),
13 'Form',
14 'Fieldset',
15 )
16 );
But it always creates one extra empty <dl/> in front of all the other form
elements. I can hide it with CSS but I'd prefer to solve the problem rather
than treat the symptom.
Any helpers out there?
Thanks in advance,
Mike Wright
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]