src/Form/Container.php
public function getForm($key, $asInstance = true)
    {
        if (false !== strpos($key, '.')) {
            list($key, $childKey) = explode('.', $key, 2);
            $container = $this->getForm($key);
            return $container->getForm($childKey);
        }
        
        if (!isset($this->forms[$key])) {
            return null;
        }
        
        $form = $this->forms[$key];

        if (!$asInstance) {
            return $form;
        }

        if (isset($form['__instance__']) && is_object($form['__instance__'])) {
            return $form['__instance__'];
        }

        $options = isset($form['options']) ? $form['options'] : array();
        if (!isset($options['name'])) {
            $options['name'] = isset($form['name']) ? $form['name'] : $key;
        }
        if (!isset($options['use_post_array'])) {
            $options['use_post_array'] = true;
        }
        if (!isset($options['use_files_array'])) {
            $options['use_files_array'] = false;
        }
        
        //@TODO: [ZF3] Passing options in $formElementManager->get is not working need to do manually set options
        $formInstance = $this->formElementManager->get($form['type'], $options);
        $formInstance->setOptions(array_merge($formInstance->getOptions(), $options));
        $formInstance->setParent($this);
        
        if (isset($form['attributes'])) {
            $formInstance->setAttributes($form['attributes']);
        }

        $formName = $this->formatAction($form['name']);
        $formInstance->setName($formName);
        $formAction = $formInstance->getAttribute('action');

        if (empty($formAction)) {
            $formInstance->setAttribute('action', '?form=' . $formName);
        }

        // @TODO: [ZF3] which one is correct? $form[options][label] or $form[options]
        if (isset($form['label'])) {
            $formLabel = $form['label'];
        } elseif (isset($form['options']['label'])) {
            $formLabel = $form['options']['label'];
        }
        
        if (isset($formLabel)) {
            $formInstance->setLabel($formLabel);
        }

        if (isset($form['disable_elements'])
            && $formInstance instanceof DisableElementsCapableInterface
            && $formInstance->isDisableElementsCapable()
        ) {
            $formInstance->disableElements($form['disable_elements']);
        }

        $entity = $this->getEntity($form['entity']);
        if ($entity) {
            $this->mapEntity($formInstance, $entity, isset($form['property']) ? $form['property'] : $key);
        }

        $formInstance->setParams($this->getParams());

        $this->forms[$key]['__instance__'] = $formInstance;
        $this->forms[$key]['options'] = $options;
        return $formInstance;
    }
public function getForm($key, $asInstance = true)
    {
        if (false !== strpos($key, '.')) {
            list($key, $childKey) = explode('.', $key, 2);
            $container = $this->getForm($key);
            return $container->getForm($childKey);
        }
        
        if (!isset($this->forms[$key])) {
            return null;
        }
        
        $form = $this->forms[$key];

        if (!$asInstance) {
            return $form;
        }

        if (isset($form['__instance__']) && is_object($form['__instance__'])) {
            return $form['__instance__'];
        }

        $options = isset($form['options']) ? $form['options'] : array();
        if (!isset($options['name'])) {
            $options['name'] = isset($form['name']) ? $form['name'] : $key;
        }
        if (!isset($options['use_post_array'])) {
            $options['use_post_array'] = true;
        }
        if (!isset($options['use_files_array'])) {
            $options['use_files_array'] = false;
        }
        
        //@TODO: [ZF3] Passing options in $formElementManager->get is not working need to do manually set options
        $formInstance = $this->formElementManager->get($form['type'], $options);
        $formInstance->setOptions(array_merge($formInstance->getOptions(), $options));
        $formInstance->setParent($this);
        
        if (isset($form['attributes'])) {
            $formInstance->setAttributes($form['attributes']);
        }

        $formName = $this->formatAction($form['name']);
        $formInstance->setName($formName);
        $formAction = $formInstance->getAttribute('action');

        if (empty($formAction)) {
            $formInstance->setAttribute('action', '?form=' . $formName);
        }

        // @TODO: [ZF3] which one is correct? $form[options][label] or $form[options]
        if (isset($form['label'])) {
            $formLabel = $form['label'];
        } elseif (isset($form['options']['label'])) {
            $formLabel = $form['options']['label'];
        }
        
        if (isset($formLabel)) {
            $formInstance->setLabel($formLabel);
        }

        if (isset($form['disable_elements'])
            && $formInstance instanceof DisableElementsCapableInterface
            && $formInstance->isDisableElementsCapable()
        ) {
            $formInstance->disableElements($form['disable_elements']);
        }

        $entity = $this->getEntity($form['entity']);
        if ($entity) {
            $this->mapEntity($formInstance, $entity, isset($form['property']) ? $form['property'] : $key);
        }

        $formInstance->setParams($this->getParams());

        $this->forms[$key]['__instance__'] = $formInstance;
        $this->forms[$key]['options'] = $options;
        return $formInstance;
    }
Gets a specific formular.

This formular will be created upon the first retrievement.
If created, the formular gets passed the formular parameters set in this container.

@param string $key
@param bool $asInstance if set to false, the specification array is returned, and no instance created.

@return null|\Core\Form\Container|\Zend\Form\FormInterface
@since 0,25 added $asInstance parameter