Reputation: 13860
I have form with fields:
$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'
),
)
);
when I use:
echo $this->formCollection($form);
in my view, I get:
[...]
<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="">
[...]
but I want to get:
[...]
<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>
[...]
How to do this?
Upvotes: 0
Views: 50
Reputation: 16455
Using the formCollection()
this is not possible. However you can do it like this:
<div id="firstid">
<?php echo $this->formRow($form->get('firstfield')); ?>
</div>
<div id="secondid">
<?php echo $this->formRow($form->get('secondfield')); ?>
</div>
If you want to have the comfort of just one function call to render the form, you'll have to extend the formCollection()
view helper with one of your own who do this.
Upvotes: 3