zendframework/zf2 — pull request #4372 by noopable (2013-05-01 15:23:56+00:00)
Title: Ability to load custom form classes from FormElementManager in Mvc.

with Mvc
```php
$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
https://github.com/zendframework/zf2/pull/4370
```php
$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".