0

フィールドのあるフォームがあります:

$this -> add(
        array(
            'name' => 'firstfield',
            'attributes' => array(
                'type'  => 'text',
                'id' => 'id_firstfield'
            ),
            'options' => array(
                'label' => 'firstfield'
            ),
        )
    );

$this -> add(
        array(
            'name' => 'secondfield',
            'attributes' => array(
                'type'  => 'text',
                'id' => 'id_secondfield'
            ),
            'options' => array(
                'label' => 'secondfield'
            ),
        )
    );

私が使用するとき:

echo $this->formCollection($form);

私の見解では、私は次のようになります。

[...]
<label for="id_firstfield">first field</label>
<input name="firstfield" type="text" id="id_firstfield" value="">
<label for="id_secondfield">second field</label>
<input name="secondfield" type="text" id="id_secondfield" value="">
[...]

しかし、私は取得したい:

[...]
<div id="divforfirstfield">
    <label for="id_firstfield">first field</label>
    <input name="firstfield" type="text" id="id_firstfield" value="">
</div>
<div id="divforsecondfield">
    <label for="id_secondfield">second field</label>
    <input name="secondfield" type="text" id="id_secondfield" value="">
</div>
[...]

これを行う方法?

4

1 に答える 1

3

これを使用するformCollection()ことはできません。ただし、次のように実行できます。

<div id="firstid">
    <?php echo $this->formRow($form->get('firstfield')); ?>
</div>
<div id="secondid">
    <?php echo $this->formRow($form->get('secondfield')); ?>
</div>

フォームをレンダリングするために1回の関数呼び出しだけで快適になりたい場合は、formCollection()これを行う独自の1人でビューヘルパーを拡張する必要があります。

于 2013-03-21T11:07:33.750 に答える