You are here

public static function TextFormat::process in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/TextFormat.php \Drupal\webform\Plugin\WebformElement\TextFormat::process()

Fix text format #more property.

Parameters

array $element: The form element to process. See main class documentation for properties.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Return value

array The form element.

See also

template_preprocess_text_format_wrapper()

text-format-wrapper.html.twig

File

src/Plugin/WebformElement/TextFormat.php, line 91

Class

TextFormat
Provides a 'text_format' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public static function process(&$element, FormStateInterface $form_state, &$complete_form) {
  if (!empty($element['#more'])) {

    // Process #more and append to #description.
    $variables = [
      'element' => $element,
      'description' => [],
    ];
    _webform_preprocess_element($variables);

    // Update element description.
    $element['#description'] = $variables['description'];

    // Remove attributes which causes conflicts.
    unset($element['#description']['attributes']);

    // Unset old #more attributes.
    unset($element['value']['#more']);
    unset($element['#more']);
  }
  return $element;
}