php – Zend Framework – 在dl中包装dt dd
发布时间:2020-12-13 16:22:09 所属栏目:PHP教程 来源:网络整理
导读:从 Change HTML output of Zend_Form中的另一个问题有谁知道我如何能够产生以下html输出? (用dl包装每个dtdd集) formfieldset dl dtlabel etc/dt ddinput etc/dd /dl dl dtlabel etc/dt ddinput etc/dd /dl/fieldset... etc/form 解决方法 这个给你: class
从
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> 解决方法
这个给你:
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('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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |