zendframework/zf2 — pull request #5220 by dhensen (2013-10-03 21:30:12+00:00)
Title: Bug fix for Zend\Form\Element\Collection::extract()

When a Traversable is encountered it is converted to an array.
By default this is done recursively, so that the Traversable becomes an array representation.
The result of that is saved in `$this->object`.
In the Colletion::extract method when iterating over `$this->object` there are two branches:

1. If there is a hydrator, its extract method is called which expects `$value` as an object.
2. If $value is an instance of the targetElement, eventualy `setObject($value)` is called on a fieldset, which also expects an object. Also the targetElement object is set to `$value`.

In both cases an object is expected, but because of recursive `iteratorToArray` call it will never be an object.

The fix is to not do it recursively, this way it still gives a key => value array representation of the traversable,
but still gives model objects that can be used by a hydrator or set as targetElement object.