zendframework / zend-form

Form component from Zend Framework
BSD 3-Clause "New" or "Revised" License
69 stars 87 forks source link

Collection has empty bonded nested objects #95

Open GeeH opened 8 years ago

GeeH commented 8 years ago

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7156 User: @epoleacov Created On: 2015-01-25T22:22:49Z Updated At: 2015-10-19T21:10:08Z Body When nested object bonded to form with related collection elements, this collection elements has just empty objects. So for example if we run next test:

ZendTest\Form\Element\CollectionTest::testCanBindObjectMultipleNestedFieldsets()

final object used for assertion should have original data ($_product->getObject()->getPrice() == 200), but it has just NULL instead.

Main cause of that is because when values extracted from collection is just takes extracted values, but forget about objects what was used in extraction which should be saved inside of collection under "object" property, which on his side used later for filling collection target elements on populateValues();

Next is line where values extracted, but objects are lost: https://github.com/zendframework/zf2/blob/b1e9f3bb3ce9cdc925139d98672af40f6b0f33d7/library/Zend/Form/Element/Collection.php#L528


Comment

User: @iprdp Created On: 2015-04-20T18:15:00Z Updated At: 2015-04-20T18:15:00Z Body I have worked around this bug by creating the targetElementInstance during extract(). Not sure if this is good enough for a fix.


Comment

User: @adamlundrigan Created On: 2015-10-19T21:10:08Z Updated At: 2015-10-19T21:10:08Z Body @epoleacov could you provide an example showing the behaviour you are seeing? I'm not having any luck reproducing what you're trying to explain


michalbundyra commented 4 years ago

This repository has been closed and moved to laminas/laminas-form; a new issue has been opened at https://github.com/laminas/laminas-form/issues/33.