脚本宝典收集整理的这篇文章主要介绍了zend-framework – 如何摆脱Zend_Form dl,dt,dd标签?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<form> <p> <label for="email" class="required">Your email address:</label> <input tyPE="text" name="email" id="email" value=""> </p> <p> <input type="submIT" name="submit" id="submit" value="Subscribe"> </p> <input type="hidden" name="active" value="true" id="active"> <input type="hidden" name="signupDate" value="" id="signupDate"> </form>
为了获得这种布局,我需要对表单做些什么?
class Default_Form_Subscribe extends Zend_Form { public function init() { $this->setMethod('post'); $this->addElement('text','email',array( 'label' => 'Email address:','required' => true,'filters' => array('StringTrim'),'validators' => array('EmailAddress') )); $this->addElement('submit','submit',array( 'label' => 'Subscribe','ignore' => true )); $this->addElement('hidden','active',array( 'value'=>'true' )); $this->addElement('hidden','signupDate',array( 'value' => Zend_Date::Now()->toString('yyYY-MM-dd') )); } }
class Default_Form_Subscribe extends Zend_Form { public function init() { $this->setMethod('post'); // reset form decorators to remove the 'dl' wrapper $this->setDecorators(array('FormElements','Form')); // custom decorator deFinition for form elements $customElementDecorators = array( 'ViewHelper','Errors',array( 'Description',array('tag' => 'p','class' => 'description') ),array( 'Label',array('separator' => ' ') ),array( array('data' => 'HtMLTag'),array('tag' => 'p') ) ); $this->addElement('text','validators' => array('EmailAddress'),'decorators' => $customElementDecorators )); $this->addElement('submit','ignore' => true,'decorators' => $customElementDecorators )); $this->addElement('hidden',array( 'value'=>'true','decorators' => array('ViewHelper') )); $this->addElement('hidden',array( 'value' => Zend_Date::Now()->toString('YYYY-MM-dd'),'decorators' => array('ViewHelper') )); } }
以上是脚本宝典为你收集整理的zend-framework – 如何摆脱Zend_Form dl,dt,dd标签?全部内容,希望文章能够帮你解决zend-framework – 如何摆脱Zend_Form dl,dt,dd标签?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。