You are here

public static function WebformCompositeBase::preRenderCompositeFormElement in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformCompositeBase.php \Drupal\webform\Element\WebformCompositeBase::preRenderCompositeFormElement()

File

src/Element/WebformCompositeBase.php, line 70

Class

WebformCompositeBase
Provides an base composite webform element.

Namespace

Drupal\webform\Element

Code

public static function preRenderCompositeFormElement($element) {
  $element['#theme_wrappers'][] = 'form_element';
  $element['#wrapper_attributes']['id'] = $element['#id'] . '--wrapper';
  $element['#wrapper_attributes']['class'][] = 'form-composite';
  $element['#attributes']['id'] = $element['#id'];

  // Add class name to wrapper attributes.
  $class_name = str_replace('_', '-', $element['#type']);
  static::setAttributes($element, [
    'js-' . $class_name,
    $class_name,
  ]);
  return $element;
}