-
Notifications
You must be signed in to change notification settings - Fork 87
Form Factory is not set when fieldsets are created via options #66
Comments
Looks the same as #58 . I only searched for this issue in open tickets. Testing with dev-master right now. |
Dev-master (#65) doesn't fix it for me. It comes down to the Ping @weierophinney |
@Netiul I've got a working unit test for this now, and am working on a solution. The plan is to override |
Also, just to clarify something:
This is not technically what's happening. The What has happened in the 2.7 and 2.8 series is that, in prepping the component to be forwards compatible with v3 releases of zend-servicemanager, we've hit a number of cases that never had unit tests. These include:
I would have expected #65 to address the situation you've outlined in your issue, and the fact that it hasn't tells me that this may actually be a different use case. I can use your code snippet from above for a unit test, and will let you know what I find. |
@weierophinney Thanks for clarifying what's changed and why. Very clear! |
@weierophinney See https://github.com/netiul/zend-form/commit/13a74999d1131339117a831ad90f7d95945e500a for a failing test. Currently this test just fails with a fatal error indicating that a dependency is not set when The So in this scenario the target element of a
You will only notice the target is being constructed twice, when the first part is causing a fatal error. Otherwise you'll always end up with the second correct constructed target element which works fine. It's not easily done writing a proper test for this without good mocking. |
This patch removes the change introduced in 2.7.1's `Zend\Form\Factory::create()` method that aggregated options and passed them to the `FormElementManager::get()` call. This usage was incorrect, as it creates an order-of-operations problem: most instances call their own `setOptions()` method from the constructor if options are present, and many of the actions this executes assume things like a populated `FormElementManager`, using a default instance if none is found! As such, reverting those changes to pre-2.7.1 usage fixes the issues reported in zendframework#66. Since the changes were done under an erroneous assumption, a test related to the incorrect functionality was also removed.
@weierophinney Does this also pertain to Fieldsets with factories rather than invokables? This problem is similar to my current issue except the main form is created via the FormAbstractServiceFactory and the fieldset has a factory mapping.
Prior to 2.7.0 the factory was used. Also, note, however, that the parent service locator actually contains the fieldset; it's the FormElementManager's service locator that does not. Correction: Knowing this, is there an understanding for the BC break? Could this be noted somewhere? |
I upgraded from 2.5 to the 2.8.1 (with zend-servicemanger 2.7.6).
I'm configuring a Form using the init function. That looks like this
My\Form\FieldsetWithDefaultElements
is instantiated via theFormElementManager
inside thecreate
method of theFormFactory
. Right after the fieldset is created by theFormElementManager
it is configured by theconfigureFieldset
and eventually theprepareAndInjectFieldsets
method iterates over the provided fieldsets options key showed above.At this point the
create
method is called with thespec
key listed above. This method fetches theZend\Form\Element\Collection
from theFormElementManager
with theoptions
key as thecreationOptions
. ThesecreationOptions
are processed on construction time because the constructor of theZend\Form\Element
is calling thesetOptions
method. At this point theCollection
doesn't have a Form Factory set yet, since it's set by the FormElementManager (via an initializer) after the Element is constructed. (TheFormFactory
gets lazy loaded, but there will be noFormElementManager
set.)The text was updated successfully, but these errors were encountered: