src/View/Helper/FormButtonIcon.php
public function render(ElementInterface $element, $buttonContent = null)
    {
        $openTag = $this->openTag($element);

        if (null === $buttonContent) {
            $buttonContent = $element->getLabel();
            $options       = $element->getOptions();

            if (null !== ($translator = $this->getTranslator())) {
                $buttonContent = $translator->translate(
                    $buttonContent, $this->getTranslatorTextDomain()
                );
            }

            /** @noinspection UnSafeIsSetOverArrayInspection */
            if (isset($options['icon'])) {
                $buttonContent = sprintf('<i class="%s"></i>%s', $options['icon'], $buttonContent);
            }
        }

        if (null === $buttonContent) {
            throw new Exception\DomainException(
                sprintf(
                    '%s expects either button content as the second argument, ' .
                    'or that the element provided has a label value; neither found',
                    __METHOD__
                )
            );
        }

        return $openTag . $buttonContent . $this->closeTag();
    }
public function render(ElementInterface $element, $buttonContent = null)
    {
        $openTag = $this->openTag($element);

        if (null === $buttonContent) {
            $buttonContent = $element->getLabel();
            $options       = $element->getOptions();

            if (null !== ($translator = $this->getTranslator())) {
                $buttonContent = $translator->translate(
                    $buttonContent, $this->getTranslatorTextDomain()
                );
            }

            /** @noinspection UnSafeIsSetOverArrayInspection */
            if (isset($options['icon'])) {
                $buttonContent = sprintf('<i class="%s"></i>%s', $options['icon'], $buttonContent);
            }
        }

        if (null === $buttonContent) {
            throw new Exception\DomainException(
                sprintf(
                    '%s expects either button content as the second argument, ' .
                    'or that the element provided has a label value; neither found',
                    __METHOD__
                )
            );
        }

        return $openTag . $buttonContent . $this->closeTag();
    }
public function render ( ElementInterface $ element , $ buttonContent = null ) { $ openTag = $ this -> openTag ( $ element ) ; if ( null === $ buttonContent ) { $ buttonContent = $ element -> getLabel ( ) ; $ options = $ element -> getOptions ( ) ; if ( null !== ( $ translator = $ this -> getTranslator ( ) ) ) { $ buttonContent = $ translator -> translate ( $ buttonContent , $ this -> getTranslatorTextDomain ( ) ) ; } /** @noinspection UnSafeIsSetOverArrayInspection */ if ( isset ( $ options [ 'icon' ] ) ) { $ buttonContent = sprintf ( '<i class="%s"></i>%s' , $ options [ 'icon' ] , $ buttonContent ) ; } } if ( null === $ buttonContent ) { throw new Exception \ DomainException ( sprintf ( '%s expects either button content as the second argument, ' . 'or that the element provided has a label value; neither found' , __METHOD__ ) ) ; } return $ openTag . $ buttonContent . $ this -> closeTag ( ) ; }
Render a form <button> element from the provided $element, using content from $buttonContent or the element's
"label" attribute.

@param ElementInterface $element
@param string           $buttonContent

@return string
@throws \Zend\Form\Exception\DomainException
@throws \Zend\Form\Exception\InvalidArgumentException
Render a form <button > element from the provided $element using content from $buttonContent or the element s label attribute .