public function render(ElementInterface $element)
    {
        $renderer = $this->getView();

        if (!method_exists($renderer, 'plugin')) {
            return '';
        }

        $wrapperClass     = '';
        $elementMarkup    = '';
        $templateMarkup   = '';
        $attributesString = '';
        $label            = '';

        if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
            $templateMarkup = $this->renderTemplate($element);
        }

        foreach ($element->getIterator() as $elementOrFieldset) {
            /** @var  ElementInterface $elementOrFieldset */
            $elementMarkup .= $this->renderElement($elementOrFieldset);
        }

        $helperFormButtonIcon = $this->getFormButtonIconHelper();
        $helperLabel          = $this->getLabelHelper();

        $elementMarkup .= sprintf(
            $this->elementWrap,
            '',
            $helperFormButtonIcon(
                new Button(
                    null,
                    [
                        'label' => 'Add New',
                        'icon'  => 'fa fa-plus-circle'
                    ]
                )
            ),
            ''
        );

        if ($this->shouldWrap) {
            $attributes = $element->getAttributes();

            /** @noinspection UnSafeIsSetOverArrayInspection */
            if (isset($attributes['class'])) {
                $wrapperClass = $attributes['class'];

                unset($attributes['class']);
            }

            unset($attributes['name']);

            $attributesString = count($attributes) ? ' ' . $this->createAttributesString($attributes) : '';

            /** @noinspection IsEmptyFunctionUsageInspection */
            if (!empty($element->getLabel())) {
                $label = $helperLabel($element);
            }
        }

        return sprintf(
            $this->wrapper,
            $wrapperClass,
            $attributesString,
            $label,
            $this->horizontalWrapClass,
            $elementMarkup,
            $templateMarkup
        );
    }
public function render(ElementInterface $element)
    {
        $renderer = $this->getView();

        if (!method_exists($renderer, 'plugin')) {
            return '';
        }

        $wrapperClass     = '';
        $elementMarkup    = '';
        $templateMarkup   = '';
        $attributesString = '';
        $label            = '';

        if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
            $templateMarkup = $this->renderTemplate($element);
        }

        foreach ($element->getIterator() as $elementOrFieldset) {
            /** @var  ElementInterface $elementOrFieldset */
            $elementMarkup .= $this->renderElement($elementOrFieldset);
        }

        $helperFormButtonIcon = $this->getFormButtonIconHelper();
        $helperLabel          = $this->getLabelHelper();

        $elementMarkup .= sprintf(
            $this->elementWrap,
            '',
            $helperFormButtonIcon(
                new Button(
                    null,
                    [
                        'label' => 'Add New',
                        'icon'  => 'fa fa-plus-circle'
                    ]
                )
            ),
            ''
        );

        if ($this->shouldWrap) {
            $attributes = $element->getAttributes();

            /** @noinspection UnSafeIsSetOverArrayInspection */
            if (isset($attributes['class'])) {
                $wrapperClass = $attributes['class'];

                unset($attributes['class']);
            }

            unset($attributes['name']);

            $attributesString = count($attributes) ? ' ' . $this->createAttributesString($attributes) : '';

            /** @noinspection IsEmptyFunctionUsageInspection */
            if (!empty($element->getLabel())) {
                $label = $helperLabel($element);
            }
        }

        return sprintf(
            $this->wrapper,
            $wrapperClass,
            $attributesString,
            $label,
            $this->horizontalWrapClass,
            $elementMarkup,
            $templateMarkup
        );
    }
public function render ( ElementInterface $ element ) { $ renderer = $ this -> getView ( ) ; if ( ! method_exists ( $ renderer , 'plugin' ) ) { return '' ; } $ wrapperClass = '' ; $ elementMarkup = '' ; $ templateMarkup = '' ; $ attributesString = '' ; $ label = '' ; if ( $ element instanceof CollectionElement && $ element -> shouldCreateTemplate ( ) ) { $ templateMarkup = $ this -> renderTemplate ( $ element ) ; } foreach ( $ element -> getIterator ( ) as $ elementOrFieldset ) { /** @var  ElementInterface $elementOrFieldset */ $ elementMarkup .= $ this -> renderElement ( $ elementOrFieldset ) ; } $ helperFormButtonIcon = $ this -> getFormButtonIconHelper ( ) ; $ helperLabel = $ this -> getLabelHelper ( ) ; $ elementMarkup .= sprintf ( $ this -> elementWrap , '' , $ helperFormButtonIcon ( new Button ( null , [ 'label' => 'Add New' , 'icon' => 'fa fa-plus-circle' ] ) ) , '' ) ; if ( $ this -> shouldWrap ) { $ attributes = $ element -> getAttributes ( ) ; /** @noinspection UnSafeIsSetOverArrayInspection */ if ( isset ( $ attributes [ 'class' ] ) ) { $ wrapperClass = $ attributes [ 'class' ] ; unset ( $ attributes [ 'class' ] ) ; } unset ( $ attributes [ 'name' ] ) ; $ attributesString = count ( $ attributes ) ? ' ' . $ this -> createAttributesString ( $ attributes ) : '' ; /** @noinspection IsEmptyFunctionUsageInspection */ if ( ! empty ( $ element -> getLabel ( ) ) ) { $ label = $ helperLabel ( $ element ) ; } } return sprintf ( $ this -> wrapper , $ wrapperClass , $ attributesString , $ label , $ this -> horizontalWrapClass , $ elementMarkup , $ templateMarkup ) ; }
Render a collection by iterating through all fieldset and elements.

@param ElementInterface $element

@return string
@throws \RuntimeException
@throws \Zend\Form\Exception\InvalidArgumentException
Render a collection by iterating through all fieldset and elements .