TwbBundle\Form\View\Helper\TwbBundleFormElement::render PHP Méthode

render() public méthode

Render an element
public render ( Zend\Form\ElementInterface $oElement ) : string
$oElement Zend\Form\ElementInterface
Résultat string
    public function render(ElementInterface $oElement)
    {
        // Add form-controll class
        $sElementType = $oElement->getAttribute('type');
        if (!in_array($sElementType, $this->options->getIgnoredViewHelpers()) && !$oElement instanceof Collection) {
            if ($sElementClass = $oElement->getAttribute('class')) {
                if (!preg_match('/(\\s|^)form-control(\\s|$)/', $sElementClass)) {
                    $oElement->setAttribute('class', trim($sElementClass . ' form-control'));
                }
            } else {
                $oElement->setAttribute('class', 'form-control');
            }
        }
        $sMarkup = parent::render($oElement);
        // Addon prepend
        if ($aAddOnPrepend = $oElement->getOption('add-on-prepend')) {
            $sMarkup = $this->renderAddOn($aAddOnPrepend) . $sMarkup;
        }
        // Addon append
        if ($aAddOnAppend = $oElement->getOption('add-on-append')) {
            $sMarkup .= $this->renderAddOn($aAddOnAppend);
        }
        if ($aAddOnAppend || $aAddOnPrepend) {
            $sSpecialClass = '';
            // Input size
            if ($sElementClass = $oElement->getAttribute('class')) {
                if (preg_match('/(\\s|^)input-lg(\\s|$)/', $sElementClass)) {
                    $sSpecialClass .= ' input-group-lg';
                } elseif (preg_match('/(\\s|^)input-sm(\\s|$)/', $sElementClass)) {
                    $sSpecialClass .= ' input-group-sm';
                }
            }
            return sprintf(self::$inputGroupFormat, trim($sSpecialClass), $sMarkup);
        }
        return $sMarkup;
    }

Usage Example

Exemple #1
0
 public function render(ElementInterface $element)
 {
     $element->setAttribute('data-role', 'datepicker');
     if ($element->getOption('default-today')) {
         $element->setAttribute('data-default-today', 'true');
     }
     return parent::render($element);
 }
All Usage Examples Of TwbBundle\Form\View\Helper\TwbBundleFormElement::render