如何以zend形式包装dt dd标签。我生成的html代码的先前格式是:
<dt id="email-label">
<label for="email" class="optional">Username(email):</label>
</dt>
<dd id="email-element">
<input type="text" name="email" id="email" value="">
</dd>
zend代码是:
$form->addElement('text', 'email');
$usernameElement = $form->getElement('email');
$usernameElement->setLabel('Username(email):');
我希望这两个标签包含在一个父标签内,如下所示:
<div id="form_wrapper">
<dt id="email-label">
<label for="email" class="optional">Username(email):</label>
</dt>
<dd id="email-element">
<input type="text" name="email" id="email" value="">
</dd>
</div>
那么我怎么能在zend框架中做到这一点?
答案 0 :(得分:1)
试试这个,
$usernameElement->setDecorators(array(
'ViewHelper',
'Label',
new Zend_Form_Decorator_HtmlTag(array('tag' => 'div','id'=>'form_wrapper'))
));