You are here

public static function YamlFormHtmlEditor::preRenderYamlFormHtmlEditor in YAML Form 8

Prepares a #type 'html_editor' render element for input.html.twig.

Parameters

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

Return value

array The $element with prepared variables ready for input.html.twig.

File

src/Element/YamlFormHtmlEditor.php, line 38

Class

YamlFormHtmlEditor
Provides a form element for entering HTML using CKEditor or CodeMirror.

Namespace

Drupal\yamlform\Element

Code

public static function preRenderYamlFormHtmlEditor($element) {
  if (\Drupal::config('yamlform.settings')
    ->get('ui.html_editor_disabled')) {
    $element['#mode'] = 'html';
    $element = YamlFormCodeMirror::preRenderYamlFormCodeMirror($element);
  }
  else {
    $element['#attached']['library'][] = 'yamlform/yamlform.element.html_editor';
    $element['#attached']['drupalSettings']['yamlform']['html_editor']['allowedContent'] = self::getAllowedContent();
  }
  return $element;
}