You are here

protected function WebformElementBase::prepareWrapper in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElementBase.php \Drupal\webform\Plugin\WebformElementBase::prepareWrapper()

Set an elements #states and flexbox wrapper.

Parameters

array $element: An element.

2 calls to WebformElementBase::prepareWrapper()
TextFormat::prepareWrapper in src/Plugin/WebformElement/TextFormat.php
Set an elements #states and flexbox wrapper.
WebformElementBase::finalize in src/Plugin/WebformElementBase.php
Finalize an element to be rendered within a webform.
1 method overrides WebformElementBase::prepareWrapper()
TextFormat::prepareWrapper in src/Plugin/WebformElement/TextFormat.php
Set an elements #states and flexbox wrapper.

File

src/Plugin/WebformElementBase.php, line 1120

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

protected function prepareWrapper(array &$element) {
  $has_states_wrapper = $this->pluginDefinition['states_wrapper'];
  $has_flexbox_wrapper = !empty($element['#webform_parent_flexbox']);
  if (!$has_states_wrapper && !$has_flexbox_wrapper) {
    return;
  }
  $class = get_class($this);

  // Fix #states wrapper.
  if ($has_states_wrapper) {
    $element['#pre_render'][] = [
      $class,
      'preRenderFixStatesWrapper',
    ];
  }

  // Add flex(box) wrapper.
  if ($has_flexbox_wrapper) {
    $element['#pre_render'][] = [
      $class,
      'preRenderFixFlexboxWrapper',
    ];
  }
}