Zend framework 如何以zend格式在同一个div中显示两个显示组?
如何在一个div中显示多个显示组 我只需要显示一个视觉分离-但在同一个分区内 有没有办法在一个div中显示多个显示组 例如:要在zend表单中实现以下功能:Zend framework 如何以zend格式在同一个div中显示两个显示组?,zend-framework,zend-form,zend-decorators,Zend Framework,Zend Form,Zend Decorators,如何在一个div中显示多个显示组 我只需要显示一个视觉分离-但在同一个分区内 有没有办法在一个div中显示多个显示组 例如:要在zend表单中实现以下功能: <div style="width: 100%;"> <div style="width: 50%; float: left; padding-left: 20px; padding-bottom: 25px;"> <fieldset id="fieldset-hom
<div style="width: 100%;">
<div style="width: 50%; float: left; padding-left: 20px; padding-bottom: 25px;">
<fieldset id="fieldset-homeAddressSettings" tag="fieldset" style="">
<legend> Home address </legend>
<!-- multiple elements follow -->
</fieldset>
</div>
<div style="width: 50%; float: left; padding-left: 20px; padding-bottom: 25px;">
<fieldset id="fieldset-officeAddressSettings" tag="fieldset" style="">
<legend> Office address </legend>
<!-- multiple elements follow -->
</fieldset>
</div>
</div>
家庭住址
办公地址
我如何在Zend表单中实现这一点
我搜索了又搜索,到目前为止还没有找到任何有用的东西。我用JavaScript解决了这个问题——它让我相信,虽然zend表单在某些方面很好,但它并不总是最好的选择。有时,它只是比它的价值更痛苦。用于“HtmlTag”装饰器的“openOnly”和“closeOnly”布尔选项正是您需要做的。正如您所了解的,openOnly的意思是,它只生成一个开始标记(即),而不生成结束标记,反之亦然,只生成closeOnly属性(即。 Zend_表单PHP代码:
$form = new Zend_Form();
// Form stuff here
$form->addDisplayGroup(
array(
'homeAddressLine1',
'homeAddressLine2',
'homeCity',
// etc
),
'homeAddress',
array(
'legend' => 'Home Address'
'disableDefaultDecorators' => true,
'decorators' => array(
'FormElements',
'FieldSet',
array('HtmlTag', array('tag' => 'div', 'class' => 'addresses', 'openOnly' => true))
)
)
);
$form->addDisplayGroup(
array(
'workAddressLine1',
'workAddressLine2',
'workCity',
// etc
),
'workAddress',
array(
'legend' => 'Work Address'
'disableDefaultDecorators' => true,
'decorators' => array(
'FormElements',
'FieldSet',
array('HtmlTag', array('tag' => 'div', 'closeOnly' => true))
)
)
);
生成的HTML:
<form <!-- Your Zend_Form attributes here -->>
<div class="addresses">
<fieldset id="fieldset-homeAddress">
<legend>Home Address</legend>
<!-- Your Home Address elements/decorators here -->
</fieldset>
<fieldset id="fieldset-workAddress">
<legend>Work Address</legend>
<!-- Your Work Address elements/decorators here -->
</fieldset>
</div>
</form>
工作地址