src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php
protected function renderAddOn($aAddOnOptions)
    {
        if (empty($aAddOnOptions)) {
            throw new InvalidArgumentException('Addon options are empty');
        }
        if ($aAddOnOptions instanceof ElementInterface) {
            $aAddOnOptions = array('element' => $aAddOnOptions);
        } elseif (is_scalar($aAddOnOptions)) {
            $aAddOnOptions = array('text' => $aAddOnOptions);
        } elseif (!is_array($aAddOnOptions)) {
            throw new InvalidArgumentException(sprintf(
                'Addon options expects an array or a scalar value, "%s" given',
                is_object($aAddOnOptions) ? get_class($aAddOnOptions) : gettype($aAddOnOptions)
            ));
        }

        $sMarkup = '';
        $sAddonTagName = 'span';
        $sAddonClass = '';
        if (!empty($aAddOnOptions['text'])) {
            if (!is_scalar($aAddOnOptions['text'])) {
                throw new InvalidArgumentException(sprintf(
                    '"text" option expects a scalar value, "%s" given',
                    is_object($aAddOnOptions['text']) ? get_class($aAddOnOptions['text']) : gettype($aAddOnOptions['text'])
                ));
            } elseif (($oTranslator = $this->getTranslator())) {
                $sMarkup .= $oTranslator->translate($aAddOnOptions['text'], $this->getTranslatorTextDomain());
            } else {
                $sMarkup .= $aAddOnOptions['text'];
            }
            $sAddonClass .= ' input-group-addon';
        } elseif (!empty($aAddOnOptions['element'])) {
            if (is_array($aAddOnOptions['element']) ||
                ($aAddOnOptions['element'] instanceof Traversable &&
                !($aAddOnOptions['element'] instanceof ElementInterface))
            ) {
                $oFactory = new Factory();
                $aAddOnOptions['element'] = $oFactory->create($aAddOnOptions['element']);
            } elseif (!($aAddOnOptions['element'] instanceof ElementInterface)) {
                throw new LogicException(sprintf(
                    '"element" option expects an instanceof Zend\Form\ElementInterface, "%s" given',
                    is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element'])
                ));
            }

            $aAddOnOptions['element']->setOptions(array_merge(
                $aAddOnOptions['element']->getOptions(),
                array('disable-twb' => true)
            ));

            $sMarkup .= $this->render($aAddOnOptions['element']);

            //Element is a button, so add-on container must be a "div"
            if ($aAddOnOptions['element'] instanceof Button) {
                $sAddonClass .= ' input-group-btn';
                $sAddonTagName = 'div';
            } else {
                $sAddonClass .= ' input-group-addon';
            }
        }

        return sprintf(static::$addonFormat, $sAddonTagName, trim($sAddonClass), $sMarkup, $sAddonTagName);
    }
protected function renderAddOn($aAddOnOptions)
    {
        if (empty($aAddOnOptions)) {
            throw new InvalidArgumentException('Addon options are empty');
        }
        if ($aAddOnOptions instanceof ElementInterface) {
            $aAddOnOptions = array('element' => $aAddOnOptions);
        } elseif (is_scalar($aAddOnOptions)) {
            $aAddOnOptions = array('text' => $aAddOnOptions);
        } elseif (!is_array($aAddOnOptions)) {
            throw new InvalidArgumentException(sprintf(
                'Addon options expects an array or a scalar value, "%s" given',
                is_object($aAddOnOptions) ? get_class($aAddOnOptions) : gettype($aAddOnOptions)
            ));
        }

        $sMarkup = '';
        $sAddonTagName = 'span';
        $sAddonClass = '';
        if (!empty($aAddOnOptions['text'])) {
            if (!is_scalar($aAddOnOptions['text'])) {
                throw new InvalidArgumentException(sprintf(
                    '"text" option expects a scalar value, "%s" given',
                    is_object($aAddOnOptions['text']) ? get_class($aAddOnOptions['text']) : gettype($aAddOnOptions['text'])
                ));
            } elseif (($oTranslator = $this->getTranslator())) {
                $sMarkup .= $oTranslator->translate($aAddOnOptions['text'], $this->getTranslatorTextDomain());
            } else {
                $sMarkup .= $aAddOnOptions['text'];
            }
            $sAddonClass .= ' input-group-addon';
        } elseif (!empty($aAddOnOptions['element'])) {
            if (is_array($aAddOnOptions['element']) ||
                ($aAddOnOptions['element'] instanceof Traversable &&
                !($aAddOnOptions['element'] instanceof ElementInterface))
            ) {
                $oFactory = new Factory();
                $aAddOnOptions['element'] = $oFactory->create($aAddOnOptions['element']);
            } elseif (!($aAddOnOptions['element'] instanceof ElementInterface)) {
                throw new LogicException(sprintf(
                    '"element" option expects an instanceof Zend\Form\ElementInterface, "%s" given',
                    is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element'])
                ));
            }

            $aAddOnOptions['element']->setOptions(array_merge(
                $aAddOnOptions['element']->getOptions(),
                array('disable-twb' => true)
            ));

            $sMarkup .= $this->render($aAddOnOptions['element']);

            //Element is a button, so add-on container must be a "div"
            if ($aAddOnOptions['element'] instanceof Button) {
                $sAddonClass .= ' input-group-btn';
                $sAddonTagName = 'div';
            } else {
                $sAddonClass .= ' input-group-addon';
            }
        }

        return sprintf(static::$addonFormat, $sAddonTagName, trim($sAddonClass), $sMarkup, $sAddonTagName);
    }
Render addo-on markup
@param string $aAddOnOptions
@throws InvalidArgumentException
@throws LogicException
@return string