You are here

public static function WebformCodeMirror::preRenderWebformCodeMirror in Webform 6.x

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

Prepares a #type 'webform_code' render element for theme_element().

Parameters

array $element: An associative array containing the properties of the element. Properties used: #title, #value, #description, #size, #maxlength, #placeholder, #required, #attributes.

Return value

array The $element with prepared variables ready for theme_element().

File

src/Element/WebformCodeMirror.php, line 131

Class

WebformCodeMirror
Provides a webform element for using CodeMirror.

Namespace

Drupal\webform\Element

Code

public static function preRenderWebformCodeMirror(array $element) {
  static::setAttributes($element, [
    'js-webform-codemirror',
    'webform-codemirror',
    $element['#mode'],
  ]);
  $element['#attributes']['data-webform-codemirror-mode'] = static::getMode($element['#mode']);
  $element['#attached']['library'][] = 'webform/webform.element.codemirror.' . $element['#mode'];
  return $element;
}