You are here

public static function WebformHtmlEditor::validateWebformHtmlEditor in Webform 6.x

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

Webform element validation handler for #type 'webform_html_editor'.

File

src/Element/WebformHtmlEditor.php, line 163

Class

WebformHtmlEditor
Provides a webform element for entering HTML using CodeMirror, TextFormat, or custom CKEditor.

Namespace

Drupal\webform\Element

Code

public static function validateWebformHtmlEditor(&$element, FormStateInterface $form_state, &$complete_form) {
  $value = $element['#value']['value'];
  if (is_array($value)) {

    // Get value from TextFormat element.
    $value = $value['value'];
  }
  else {
    $value = trim($value);
  }
  $element['#value'] = $value;
  $form_state
    ->setValueForElement($element, $value);
}