-
Notifications
You must be signed in to change notification settings - Fork 87
Fix collection hydration problem #19
Fix collection hydration problem #19
Conversation
There is one invalid test not sure if this is related. It's possible due other bug or not :) Line 355 in 6da5316
shouldn't it return Line 377 in 6da5316
|
I don't think this is the right place to solve this. What if I don't want to update the collection, but instead it is cleared now? |
@DASPRiD I`m totally agree. We still need a way not to send a collection and leave it as is without clearing. But we need a way to send an empty array and clear the collection also. |
@DASPRiD how would you determine that you need clear or not? also if you want to leave collection you could just remove collection fieldset from form no? |
@DASPRiD I think that not clearing collection on object is not a good idea because form collection is cleared anyway and won't render. This is just hydrator part that ignores that collection in form is empty and should be cleared. What do you think? |
Can we get any more input on this? This seriously is a big issue that we need to tackle. On literally every project im running into this code:
and that's just insane. I think that the approach outlined here is perfectly valid. However this changes default behavior in a pretty drastic way. I would suggest to add an option to the hydrator implementation that would enable this feature. Something like Kind of have to pick my own nose as far as blaming goes, but truthfully we're at 2.6 now and an issue of this scale still persists :D that's kinda not good ^^ pingflood for some more input on the concern @DASPRiD @bakura10 @weierophinney |
@manuakasam i don't think that this kind of option is good because form collection is cleared anyway, if you try to render form you wont get any items from collection as they are cleared. As I said this is just hydrator that does not do its job and not clear collection. Maybe this option would be some kind of workaround for BC if any, but not more. You have few options to not remove collection without this option:
Also as this is enterprise framework having this issue from version 2.0 to 2.6 is pretty disappointing. I hope this will not go into 3.0 I would also like more input on this how ZF team want this to be handled? |
Don't get me wrong. The option solution simply came to mind due to the input that dasprid has Vytautas Stankus [email protected] schrieb am Fr., 30. Okt. 2015
|
👍 for getting this as fast as possible! |
This is definitely a general design flaw within Zend\Form. Personally I'd in fact argue that if As far as I can judge, this should not be solved in the InputFilter. |
👍 Need this ASAP! |
Any news on this? |
@FabianKoestring I am not sure where we are. @DASPRiD said he doesn't like this. So I am waiting for suggestions how this could be fixed, but I guess ZF team is too busy with ZF3 to answer this :) lets hope they will fix it in ZF3 :D |
I'm inclined to bring this in verbatim. The current workarounds necessary to allow the forms to validate are not trivial to learn; if a collection is required, an empty set will typically cause the collection to invalidate anyways. Scheduling for next maintenance release (2.7.1). |
Hm, interestingly there's a new test failure as a result of this change: |
Found the problem, and really unsure how to go about addressing it. Essentially, this patch has exposed a subtle bug that was masquerading as a feature. The test was checking to ensure that a value in a nested fieldset, when resubmitted, would not change. What's interesting is that, in stepping through the code, it appears that the reason it worked previously was because the nested fieldset was being silently ignored during binding. The test was passing, but because the scenario it described just happened to also be the result of an issue. To dive deeper, when I stepped through the code, the input filter was not returning the I've tried a few different approaches:
Neither had an effect. In the first case, the prepared data is still pulled from the input filter, and is thus missing the Essentially, there's a far deeper issue here, and, unfortunately, while it's a bug, the fact is that the patch still represents a change in expected behavior, and has the potential of breaking existing applications. As such, I'm removing it from the 2.7.1 milestone until that can be resolved. |
@weierophinney should I try to fix this bug in this PR? Are you planning to to fix this by yourself in another PR or what? this is pretty annoying bug. Should I rebase? But I'm not sure this will be merged at all :) |
@svycka Rebase, and see if you can figure out how to make it work, please, based on the analysis I did above. 😄 |
bfd7ce3
to
767818d
Compare
@weierophinney I need some help. I think found the problem, but not sure I understand how this should work and if this is a bug. Can you explain what is going on here: https://github.com/zendframework/zend-form/blob/master/src/Form.php#L818-L840 I have added |
@weierophinney I added coveralls fix into this PR because I needed coverage. Can revert if you want. |
ping @weierophinney |
I dont want to spam around but why isnt this merged? |
866991f
to
3b06c5a
Compare
3b06c5a
to
82b0cdc
Compare
rebased, squahed and moved unrelated coveralls fix maybe this will make things faster? :) I am still not sure if this is not a bug, but can't imagine form without There is the line where empty inputFilter is added: Line 839 in 82b0cdc
|
In that code block,
What's interesting about this is that So, as such, that's not a bug; it's just protective coding. 😁 Reviewing to merge, as I discovered that we also need to add zend-i18n as a direct requirement (view helpers depend on it), forcing a 2.9.0 release. |
$addressesFieldeset->remove('city'); | ||
$addressesFieldset = new \ZendTest\Form\TestAsset\AddressFieldset(); | ||
$addressesFieldset->setHydrator(new \Zend\Hydrator\ClassMethods()); | ||
$addressesFieldset->remove('city'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this typo. 😄
…ection Fix collection hydration problem
as @write2art commented that #14 didn't fixed everything. So this is suggestion how that could be fixed.
feedback is welcome as I am not sure this is the best way to fix it.