src/Form/View/Helper/Form.php
public function renderBare(FormInterface $form, $layout = self::LAYOUT_HORIZONTAL, $parameter = array())
    {
        /* @var $renderer \Zend\View\Renderer\PhpRenderer
         * @var $headscript \Zend\View\Helper\HeadScript
         * @var $basepath \Zend\View\Helper\BasePath */
        $renderer   = $this->getView();
        $headscript = $renderer->plugin('headscript');
        $basepath   = $renderer->plugin('basepath');
        
        $headscript->appendFile($basepath('modules/Core/js/core.spinnerbutton.js'))
                   //->appendFile($basepath('/assets/select2/js/select2.min.js'))
                   ->appendFile($basepath('modules/Core/js/core.forms.js'));

        /* @noinspection PhpParamsInspection */
        //$renderer->headLink()->appendStylesheet($basepath('/assets/select2/css/select2.css'));

        if ($scripts = $form->getOption('headscript')) {
            if (!is_array($scripts)) {
                $scripts = array($scripts);
            }
            foreach ($scripts as $script) {
                $headscript->appendFile($basepath($script));
            }
        }
        
        $class = $form->getAttribute('class');
        $class = preg_replace('~\bform-[^ ]+\b~', '', $class);
        $class .= ' ' . $layout;
        
        $form->setAttribute('class', $class);

        $formId = $form->getAttribute('id') ?: $form->getName();
        $formId = preg_replace(
            array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'),
            array('-'              , '-'    , ''       ),
            $formId
        );
        $form->setAttribute(
            'id',
            $formId

        );

        if (method_exists($form, 'prepare')) {
            $form->prepare();
        }
    
        $formContent = '';
    
        if ($form instanceof ViewPartialProviderInterface) {
            return $renderer->partial($form->getViewPartial(), array_merge(['element' => $form], $parameter));
        }

        /* @var $element \Zend\Form\ElementInterface */
        foreach ($form as $element) {
            $parameterPartial = $parameter;
            $elementId = $element->getAttribute('id');
            if (!$elementId) {
                $elementId = preg_replace(
                    array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'),
                    array('-'             , '-',     ''),
                    $element->getName()
                );
            }
            $element->setAttribute('id', "$formId-$elementId");
            $element->setOption('__form_id__', $formId);
            if ($element instanceof ExplicitParameterProviderInterface) {
                /* @var $element ExplicitParameterProviderInterface */
                $parameterPartial = array_merge($element->getParams(), $parameterPartial);
            }

            if ($element instanceof ViewPartialProviderInterface) {
                /* @var $element ViewPartialProviderInterface */
                $parameterPartial = array_merge(array('element' => $element, 'layout' => $layout), $parameterPartial);
                /** @noinspection PhpToStringImplementationInspection */
                $formContent .= $renderer->partial(
                    $element->getViewPartial(),
                    $parameterPartial
                );
            } elseif ($element instanceof FieldsetInterface) {
                if ($element instanceof ViewHelperProviderInterface) {
                    /* @var $element ViewHelperProviderInterface */
                    $helper = $element->getViewHelper();
                    if (is_string($helper)) {
                        $helper = $renderer->plugin($helper);
                    }

                    $formContent .= $helper($element);
                } else {
                    $formContent .= $renderer->formCollection($element, true, $layout);
                }
            } elseif (false !== $element->getOption('use_formrow_helper')) {
                $formContent .= $renderer->formRow($element, null, null, $layout);
            } else {
                $formContent .= $renderer->formElement($element);
            }
        }
        
        return $this->openTag($form) . $formContent . $this->closeTag();
    }
public function renderBare(FormInterface $form, $layout = self::LAYOUT_HORIZONTAL, $parameter = array())
    {
        /* @var $renderer \Zend\View\Renderer\PhpRenderer
         * @var $headscript \Zend\View\Helper\HeadScript
         * @var $basepath \Zend\View\Helper\BasePath */
        $renderer   = $this->getView();
        $headscript = $renderer->plugin('headscript');
        $basepath   = $renderer->plugin('basepath');
        
        $headscript->appendFile($basepath('modules/Core/js/core.spinnerbutton.js'))
                   //->appendFile($basepath('/assets/select2/js/select2.min.js'))
                   ->appendFile($basepath('modules/Core/js/core.forms.js'));

        /* @noinspection PhpParamsInspection */
        //$renderer->headLink()->appendStylesheet($basepath('/assets/select2/css/select2.css'));

        if ($scripts = $form->getOption('headscript')) {
            if (!is_array($scripts)) {
                $scripts = array($scripts);
            }
            foreach ($scripts as $script) {
                $headscript->appendFile($basepath($script));
            }
        }
        
        $class = $form->getAttribute('class');
        $class = preg_replace('~\bform-[^ ]+\b~', '', $class);
        $class .= ' ' . $layout;
        
        $form->setAttribute('class', $class);

        $formId = $form->getAttribute('id') ?: $form->getName();
        $formId = preg_replace(
            array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'),
            array('-'              , '-'    , ''       ),
            $formId
        );
        $form->setAttribute(
            'id',
            $formId

        );

        if (method_exists($form, 'prepare')) {
            $form->prepare();
        }
    
        $formContent = '';
    
        if ($form instanceof ViewPartialProviderInterface) {
            return $renderer->partial($form->getViewPartial(), array_merge(['element' => $form], $parameter));
        }

        /* @var $element \Zend\Form\ElementInterface */
        foreach ($form as $element) {
            $parameterPartial = $parameter;
            $elementId = $element->getAttribute('id');
            if (!$elementId) {
                $elementId = preg_replace(
                    array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'),
                    array('-'             , '-',     ''),
                    $element->getName()
                );
            }
            $element->setAttribute('id', "$formId-$elementId");
            $element->setOption('__form_id__', $formId);
            if ($element instanceof ExplicitParameterProviderInterface) {
                /* @var $element ExplicitParameterProviderInterface */
                $parameterPartial = array_merge($element->getParams(), $parameterPartial);
            }

            if ($element instanceof ViewPartialProviderInterface) {
                /* @var $element ViewPartialProviderInterface */
                $parameterPartial = array_merge(array('element' => $element, 'layout' => $layout), $parameterPartial);
                /** @noinspection PhpToStringImplementationInspection */
                $formContent .= $renderer->partial(
                    $element->getViewPartial(),
                    $parameterPartial
                );
            } elseif ($element instanceof FieldsetInterface) {
                if ($element instanceof ViewHelperProviderInterface) {
                    /* @var $element ViewHelperProviderInterface */
                    $helper = $element->getViewHelper();
                    if (is_string($helper)) {
                        $helper = $renderer->plugin($helper);
                    }

                    $formContent .= $helper($element);
                } else {
                    $formContent .= $renderer->formCollection($element, true, $layout);
                }
            } elseif (false !== $element->getOption('use_formrow_helper')) {
                $formContent .= $renderer->formRow($element, null, null, $layout);
            } else {
                $formContent .= $renderer->formElement($element);
            }
        }
        
        return $this->openTag($form) . $formContent . $this->closeTag();
    }
Render a form from the provided $form,

@param FormInterface $form
@param string $layout
@param array $parameter
@return string