I've opened a ticket with Zend about this issue, but I was hoping to get some help sooner.
I have a form with nested Collections. Lets say the data I submit to the form has 2 items in a collection with an additional nested collection, like this:
array(
array(
'foo' => 'bazbat',
'bar' => '12345',
'baz' => '',
'nest' => array(
'foo' => 'foobar',
'bar' => '111111',
'baz' => '',
),
),
array(
'foo' => 'batbaz',
'bar' => '54321',
'baz' => '',
'nest' => array(
'foo' => 'foobat',
'bar' => '222222',
'baz' => '',
),
)
);
The above example work fine. However, if the second collection does not have a "nest" input (empty Collection) the "nest" collection from the first collection is added to the second.
Example:
$form = new \Zend\Form\Form();
$form->setData(array(
array(
'foo' => 'bazbat',
'bar' => '12345',
'baz' => '',
'nest' => array(
'foo' => 'foobar',
'bar' => '111111',
'baz' => '',
),
),
array(
'foo' => ' batbaz ',
'bar' => '54321',
'baz' => '',
)
));
$form->isValid();
$data = $form->getData();
$data looks like
array(
array(
'foo' => 'bazbat',
'bar' => '12345',
'baz' => '',
'nest' => array(
'foo' => 'foobar',
'bar' => '111111',
'baz' => '',
),
),
array(
'foo' => ' batbaz ',
'bar' => '54321',
'baz' => '',
'nest' => array(
'foo' => 'foobar',
'bar' => '111111',
'baz' => '',
),
)
));
I'm almost positive the issue is with \Zend\InputFilter\CollectionInputFilter, but I haven't been able to find a good solution.