Ability to load custom form classes from FormElementManager in Mvc. #4372

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@noopable
Contributor
noopable commented May 1, 2013

with Mvc

$formElementManager = $serviceLocator->get('FormElementManager');
$form = $formElementManager->get('MyApplication\Form\ContactForm');

raise Exception
Caused by
Zend\Form\Exception\InvalidElementException: Plugin of type Zend\Form\Factory is invalid; must implement Zend\Form\ElementInterface

Because the ElementInterface depends on Zend\Form\Factory and the FormElementManager tries to get from DiAbstractFactory in it(as ServiceManager). So the FormElementManager::validatePlugin throws Exception.
We can avoid this corruption with setting Application's ServiceLocator as peeringServiceManager. yes.

Next, the ElementPrepareAwareInterface requires 'Zend\Form\FormInterface'.

cause
Zend\Di\Exception\RuntimeException: Invalid instantiator of type "NULL" for "Zend\Form\FormInterface".

Thus feed a mock object to type-preference

If the ElementPrepareAwareInterface problem (issue #3818 and PR #4370) was resolved, Feeding type-preferences is not necessary.

relative to #3818
#4370

        $di = new \Zend\Di\Di;
        $element = $di->get('Zend\Form\Form');

raise
'Zend\Di\Exception\RuntimeException' with message 'Invalid instantiator of type "NULL" for "Zend\Form\FormInterface".

@weierophinney weierophinney was assigned May 1, 2013
@weierophinney weierophinney added a commit that referenced this pull request May 1, 2013
@weierophinney weierophinney Merge branch 'hotfix/4372' into develop
Close #4372
Fixes #3818
Fixes #3812
8c92fdb
@weierophinney
Member

Closed with #4372

@noopable noopable deleted the noopable:patch-FormElementManager-retrieval branch Dec 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment