0

I created a collection of inputs with Zend\Form\Element\Collection, like

 $this->add([
        'type' => 'Zend\Form\Element\Collection',
        'name' => 'some-name',
        'options' => [
            'label' => 'some name',
            'count' => 3,
            'target_element' => [
                'type' => 'text',
            ],
        ],
    ]);

This codes renders 3 inputs with label and fieldset if I use

echo $this->formCollection($form->get('some-name'));

(or the like of formCollection) in the view script.

I want to wrap each input of the collection into divs. My idea is to iterate over this input collection to extract the inputs.

How can I do this?

Dima Dz
  • 512
  • 1
  • 5
  • 17

1 Answers1

1

You can treat the collection as a traversable object.

<?php foreach ($form->get('some-name') as $element) : ?>
  <div>..</div>
<?php endforeach; ?>
Pradeep
  • 2,469
  • 1
  • 18
  • 27