Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

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

Conversation

noopable
Copy link
Contributor

@noopable 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".

@ghost ghost assigned weierophinney May 1, 2013
weierophinney added a commit that referenced this pull request May 1, 2013
…eval

Ability to load custom form classes from FormElementManager in Mvc.
weierophinney added a commit that referenced this pull request May 1, 2013
@weierophinney
Copy link
Member

Closed with #4372

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants