如何以zend形式在同一div中显示2个显示组?

Mal*_*yer 1 zend-framework zend-form zend-decorators

如何在div中显示多个显示组?

我只需要显示一个视觉分离 - 但在同一个div内.

有没有办法在div中显示多个显示组?

例如:以zend形式实现以下内容:

  <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>
Run Code Online (Sandbox Code Playgroud)

我怎样才能在Zend表单中实现这一点?

我搜索和搜索到目前为止我还没有找到任何有用的东西.

Ank*_*wal 7

'HtmlTag'装饰器的'openOnly'和'closeOnly'布尔选项完全符合您的需要.正如您所知,openOnly意味着它只生成一个开始标记(即)而没有结束标记,反之亦然,因为closeOnly属性(即

Zend_Form 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))
        )
    )
);
Run Code Online (Sandbox Code Playgroud)

生成的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>
Run Code Online (Sandbox Code Playgroud)