Example #1
0
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (is_string($content) && $element && $form) {
         $elements = $this->getFieldsetElements($element, $form);
         if (!isset($elements[$content])) {
             return '';
         }
         $content = $elements[$content];
     }
     if ($content instanceof ElementInterface) {
         $helper = $this->getElementHelper();
         $decorators = (array) $content->getOption($helper->getDecoratorNamespace());
         // Disable row decorator
         $decorators['row']['placement'] = false;
         $content->setOption(FormRow::RENDERED, null);
         $content->setOption($helper->getDecoratorNamespace(), $decorators);
     }
     $markup = parent::render($content, $attribs, $element, $form);
     if ($content instanceof ElementInterface) {
         if ($this->isElementHasError($content, $form)) {
             $element->setOption('has_error', true);
         }
         if ($content->getOption('has_feedback')) {
             $element->setOption('has_feedback', true);
         }
     }
     return $markup;
 }
Example #2
0
File: Btn.php Project: coolms/twbs
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     $renderAsBlock = $this->renderAsBlock;
     if ($form && $renderAsBlock) {
         $class = $form->getAttribute('class');
         if (strpos($class, 'form-inline') !== false || strpos($class, 'form-horizontal') === false) {
             $renderAsBlock = false;
         }
     }
     if ($renderAsBlock) {
         if (empty($attribs['class'])) {
             $attribs['class'] = 'btn-block';
         } elseif (strpos($attribs['class'], 'btn-block') === false && strpos($attribs['class'], 'btn-inline') === false) {
             $attribs['class'] = $attribs['class'] . ' btn-block';
         }
     }
     return parent::render($content, $attribs, $element, $form);
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if ($content instanceof ElementInterface) {
         if (!$content instanceof Element\Checkbox && !$content instanceof Element\MonthSelect && !$content instanceof Element\Button && !$content instanceof Element\Submit && $content->getAttribute('type') !== 'hidden') {
             if ($content instanceof Element\Select) {
                 if ($content->getEmptyOption() && $content->getLabelOption('sr_only') === null) {
                     $content->setLabelOption('sr_only', true);
                 }
             } elseif ($content instanceof LabelAwareInterface && $content->getLabel() && !$content->hasAttribute('placeholder')) {
                 $content->setAttribute('placeholder', $content->getLabel());
             }
             if ($form && $this->isElementHasError($content, $form)) {
                 if (!$content->hasAttribute('id')) {
                     $idNormalizer = $this->getIdNormalizer();
                     $content->setAttribute('id', $idNormalizer($content->getName()));
                 }
                 $content->setAttribute('aria-describedby', $content->getAttribute('id') . '-status');
             }
         }
     }
     return parent::render($content, $attribs, $element, $form);
 }