2

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>

Zendフォームでこれを達成するにはどうすればよいですか?

私は検索して検索しましたが、これまでに役立つものは何も見つかりませんでした。

4

2 に答える 2

8

「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))
        )
    )
);

生成された 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>
于 2010-03-26T15:52:09.013 に答える
1

私はこれを JavaScript で解決しました。zend フォームは何かには適していますが、常に最適なオプションであるとは限らないことを確信しました。時々、その価値よりも苦痛です。

于 2010-02-05T16:43:26.683 に答える