original_string: public function render(Element $element)
      {
          // For all non-checkbox fields...
          if ($element instanceof AbstractFormField && !$element instanceof CheckBox) {
              if (!$element->getId()) {
                  $element->setId('field-' . uniqid());
              }
  
              // Render our label
              $label = new Tag('label');
              $label->setAttribute('for', $element->getId());
              $label->setInnerHtml($element->getTitle());
  
              // If no labels are wanted, we set it to "Screen Reader" only,
              // @see http://getbootstrap.com/css/#callout-inline-form-labels
              if ($this->mode == self::MODE_INLINE_NO_LABELS) {
                  $label->setAttribute('class', 'sr-only');
              }
  
              // Render our field, but with an css class "form-control"
              $element->addClass('form-control');
              $field = parent::render($element);
  
              // Render a help block if an help-text is set.
              $helpBlock = '';
              if ($element->getHelpText()) {
                  $helpTag = new Tag('p');
                  $helpTag->setAttribute('class', 'help-block');
                  $helpTag->setInnerHtml($element->getHelpText());
                  $helpBlock = $helpTag->render();
              }
  
              // Now render our container div, which will contain all of the above
              $tag = new Tag('div');
              $cssClass = 'form-group';
  
              if ($element->getForm()->isSubmitted()) {
                  if (!$element->isValid()) {
                      $cssClass .= ' has-error has-feedback';
                  } else {
                      $cssClass .= ' has-success has-feedback';
                  }
              }
  
              $tag->setAttribute('class', $cssClass);
  
              $tag->setInnerHtml(
                  $label->render() . PHP_EOL .
                  $field . PHP_EOL .
                  $helpBlock . PHP_EOL
              );
  
              return $tag->render();
  
          } elseif ($element instanceof AbstractFormButton) {
              $element->addClass('btn');
  
              $buttons = $element->getForm()->getFieldsByClass('\FormHandler\Field\AbstractFormButton');
              if (sizeof($buttons) == 1) {
                  $element->addClass('btn-primary');
              }
  
              return parent::render($element);
          }
          return parent::render($element);
      }
code: public function render(Element $element)
      {
          // For all non-checkbox fields...
          if ($element instanceof AbstractFormField && !$element instanceof CheckBox) {
              if (!$element->getId()) {
                  $element->setId('field-' . uniqid());
              }
  
              // Render our label
              $label = new Tag('label');
              $label->setAttribute('for', $element->getId());
              $label->setInnerHtml($element->getTitle());
  
              // If no labels are wanted, we set it to "Screen Reader" only,
              // @see http://getbootstrap.com/css/#callout-inline-form-labels
              if ($this->mode == self::MODE_INLINE_NO_LABELS) {
                  $label->setAttribute('class', 'sr-only');
              }
  
              // Render our field, but with an css class "form-control"
              $element->addClass('form-control');
              $field = parent::render($element);
  
              // Render a help block if an help-text is set.
              $helpBlock = '';
              if ($element->getHelpText()) {
                  $helpTag = new Tag('p');
                  $helpTag->setAttribute('class', 'help-block');
                  $helpTag->setInnerHtml($element->getHelpText());
                  $helpBlock = $helpTag->render();
              }
  
              // Now render our container div, which will contain all of the above
              $tag = new Tag('div');
              $cssClass = 'form-group';
  
              if ($element->getForm()->isSubmitted()) {
                  if (!$element->isValid()) {
                      $cssClass .= ' has-error has-feedback';
                  } else {
                      $cssClass .= ' has-success has-feedback';
                  }
              }
  
              $tag->setAttribute('class', $cssClass);
  
              $tag->setInnerHtml(
                  $label->render() . PHP_EOL .
                  $field . PHP_EOL .
                  $helpBlock . PHP_EOL
              );
  
              return $tag->render();
  
          } elseif ($element instanceof AbstractFormButton) {
              $element->addClass('btn');
  
              $buttons = $element->getForm()->getFieldsByClass('\FormHandler\Field\AbstractFormButton');
              if (sizeof($buttons) == 1) {
                  $element->addClass('btn-primary');
              }
  
              return parent::render($element);
          }
          return parent::render($element);
      }
code_tokens: public function render ( Element $ element ) { // For all non-checkbox fields... if ( $ element instanceof AbstractFormField && ! $ element instanceof CheckBox ) { if ( ! $ element -> getId ( ) ) { $ element -> setId ( 'field-' . uniqid ( ) ) ; } // Render our label $ label = new Tag ( 'label' ) ; $ label -> setAttribute ( 'for' , $ element -> getId ( ) ) ; $ label -> setInnerHtml ( $ element -> getTitle ( ) ) ; // If no labels are wanted, we set it to "Screen Reader" only, // @see http://getbootstrap.com/css/#callout-inline-form-labels if ( $ this -> mode == self :: MODE_INLINE_NO_LABELS ) { $ label -> setAttribute ( 'class' , 'sr-only' ) ; } // Render our field, but with an css class "form-control" $ element -> addClass ( 'form-control' ) ; $ field = parent :: render ( $ element ) ; // Render a help block if an help-text is set. $ helpBlock = '' ; if ( $ element -> getHelpText ( ) ) { $ helpTag = new Tag ( 'p' ) ; $ helpTag -> setAttribute ( 'class' , 'help-block' ) ; $ helpTag -> setInnerHtml ( $ element -> getHelpText ( ) ) ; $ helpBlock = $ helpTag -> render ( ) ; } // Now render our container div, which will contain all of the above $ tag = new Tag ( 'div' ) ; $ cssClass = 'form-group' ; if ( $ element -> getForm ( ) -> isSubmitted ( ) ) { if ( ! $ element -> isValid ( ) ) { $ cssClass .= ' has-error has-feedback' ; } else { $ cssClass .= ' has-success has-feedback' ; } } $ tag -> setAttribute ( 'class' , $ cssClass ) ; $ tag -> setInnerHtml ( $ label -> render ( ) . PHP_EOL . $ field . PHP_EOL . $ helpBlock . PHP_EOL ) ; return $ tag -> render ( ) ; } elseif ( $ element instanceof AbstractFormButton ) { $ element -> addClass ( 'btn' ) ; $ buttons = $ element -> getForm ( ) -> getFieldsByClass ( '\FormHandler\Field\AbstractFormButton' ) ; if ( sizeof ( $ buttons ) == 1 ) { $ element -> addClass ( 'btn-primary' ) ; } return parent :: render ( $ element ) ; } return parent :: render ( $ element ) ; }
docstring: This method is executed when an Element needs to be rendered.
  Here we add some logic to add the label, an optional help block and the form group.
  @param Element $element
  @return string
docstring_tokens: This method is executed when an Element needs to be rendered . Here we add some logic to add the label an optional help block and the form group .