从Change HTML output of Zend_Form中的另一个问题有谁知道我如何能够产生以下html输出? (用dl包装每个dtdd集)
<form>
<fieldset>
<dl>
<dt>label etc</dt>
<dd>input etc</dd>
</dl>
<dl>
<dt>label etc</dt>
<dd>input etc</dd>
</dl>
</fieldset>
... etc
</form>
答案 0 :(得分:3)
你在这里:
class Default_Form_Chip extends Zend_Form
{
protected $_element_decorators = array(
'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'form_element')),
array('Label', array('tag' => 'dt', 'class' => 'required', 'tagClass' => 'form_label')),
array('HtmlTag', array('tag' => 'dl', 'class' => 'form_wrapper')),
);
//put your code here
public function init()
{
$this->setElementDecorators($this->_element_decorators);
$this->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'fieldset')),
'Form',
));
$this->addElement('text', 'username',array(
'label'=>'Username'
));
$this->addElement('text', 'password',array(
'label'=>'Password'
));
}
}
输出html:
<form enctype="application/x-www-form-urlencoded" action="" method="post">
<fieldset>
<dl class="form_wrapper">
<dt id="username-label">Username</dt>
<dd class="form_element">
<input type="text" name="username" id="username" value="">
</dd>
</dl>
<dl class="form_wrapper">
<dt id="password-label">Password</dt>
<dd class="form_element">
<input type="text" name="password" id="password" value="">
</dd>
</dl>
</fieldset>
</form>