コード例 #1
0
ファイル: FormGroup.php プロジェクト: coolms/twbs
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if ($class = $this->getElementStateClass($element, $form)) {
         $attribs = array_merge_recursive(compact('class'), $attribs);
     }
     return parent::render($content, $attribs, $element, $form);
 }
コード例 #2
0
ファイル: ElementDescription.php プロジェクト: coolms/common
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (!$content && !($content = $element->getOption('description'))) {
         return '';
     }
     return parent::render($content, $attribs, $element, $form);
 }
コード例 #3
0
ファイル: InputGroupAddon.php プロジェクト: coolms/twbs
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if ($element) {
         $element->setOption('input_group', true);
     }
     return parent::render($content, $attribs, $element, $form);
 }
コード例 #4
0
ファイル: FormControlFeedback.php プロジェクト: coolms/twbs
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (!$content && !$form) {
         return '';
     }
     if (!$form || !$element) {
         return parent::render($content, $attribs);
     }
     $content = $content ?: $this->getFeedbackContent($element, $form);
     if (!$content) {
         return '';
     }
     if (strpos($element->getAttribute('class'), 'form-control') !== false && ($element instanceof Element\Text || $element instanceof Element\Password || $element instanceof Element\Number || $element instanceof Element\Email || $element instanceof Element\Url)) {
         $element->setOption('has_feedback', true);
         if (empty($attribs['aria-hidden'])) {
             $attribs['aria-hidden'] = 'true';
         }
     }
     $feedbackHelper = $this->getFeedbackHelper();
     $content = $feedbackHelper($content, $this->mergeAttributes($attribs));
     if ($element->hasAttribute('aria-describedby') && ($status = $this->getStatusContent($element, $form))) {
         $formControlStatusHelper = $this->getFormControlStatusHelper();
         $content .= $formControlStatusHelper("({$status})", ['id' => $element->getAttribute('aria-describedby')]);
     }
     return $content;
 }
コード例 #5
0
ファイル: ElementErrors.php プロジェクト: coolms/common
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (!$this->isElementHasError($element, $form)) {
         return '';
     }
     if (!$content) {
         $formElementErrorsHelper = $this->getFormElementErrorsHelper();
         $content = $formElementErrorsHelper($element, $this->mergeAttributes($attribs));
     }
     return parent::render($content, $attribs, $element, $form);
 }
コード例 #6
0
ファイル: HelpBlock.php プロジェクト: coolms/twbs
 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (!$content) {
         $elementDescriptionDecorator = $this->getElementDescriptionDecorator();
         $elementErrorsDecorator = $this->getElementErrorsDecorator();
         $content = $elementDescriptionDecorator(null, ['class' => 'form-control-description'], $element, $form) . $elementErrorsDecorator(null, [], $element, $form);
         if (!$content) {
             return '';
         }
     }
     return parent::render($content, $attribs, $element, $form);
 }
コード例 #7
0
ファイル: Element.php プロジェクト: coolms/common
 /**
  * {@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])) {
             $content = $elements[$content];
         }
     }
     if ($content instanceof ElementInterface) {
         $content->setAttributes($this->mergeAttributes($attribs));
         if (!$content->hasAttribute('id')) {
             $idNormalizer = $this->getIdNormalizer();
             $content->setAttribute('id', $idNormalizer($content->getName()));
         }
         if ($content instanceof FieldsetInterface) {
             $rendered = $this->renderHelper($content, false, true);
         } else {
             $rendered = $this->renderHelper($content, $form);
         }
         $content->setOption(FormRow::RENDERED, true);
         return $rendered;
     }
     return parent::render($content, $attribs, $element, $form);
 }