You are here

public static function WebformMarkup::preRenderWebformMarkup in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformMarkup.php \Drupal\webform\Element\WebformMarkup::preRenderWebformMarkup()

Create webform markup for rendering.

Parameters

array $element: An associative array containing the properties and children of the element.

Return value

array The modified element with webform html markup.

File

src/Element/WebformMarkup.php, line 36

Class

WebformMarkup
Provides a render element for webform markup.

Namespace

Drupal\webform\Element

Code

public static function preRenderWebformMarkup(array $element) {

  // Make sure that #markup is defined.
  if (!isset($element['#markup'])) {
    return $element;
  }

  // Replace #markup with renderable webform HTML editor markup.
  $element['markup'] = WebformHtmlEditor::checkMarkup($element['#markup'], [
    'tidy' => FALSE,
  ]);
  unset($element['#markup']);

  // Must set wrapper id attribute since we are no longer including #markup.
  // @see template_preprocess_form_element()
  if (isset($element['#theme_wrappers']) && !empty($element['#id'])) {
    $element['#wrapper_attributes']['id'] = $element['#id'];
  }

  // Sent #name property which is used by form-item-* classes.
  if (!isset($element['#name']) && isset($element['#webform_key'])) {
    $element['#name'] = $element['#webform_key'];
  }
  return $element;
}