Last Updated: February 25, 2016
· code_arts

Set hydrator to Zend Element Collections only if the target fieldset does not have any Collections

Zend\Form\Element\Collection allows to set a hydrator that will be used per fieldset object in the collection. This is the straightforward way to hydrate/extract.

But if any of your elements in the Collections target fieldset is a Collections element, the extract is not propagated to the inner Collections hydrator.

For this to work, do not set the Collections hydrator. Instead, set the hydrator of the target fieldset. Now each object in the collection will check if the target fieldset has a hydrator and call it.

Refer: Zend\Form\Element\Collection::extract()