You are here

public static function WebformElementBase::preRenderFixFlexboxWrapper in Webform 8.5

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

Fix flexbox wrapper.

Parameters

array $element: An element.

Return value

array An element with flexbox wrapper added to the #prefix and #suffix.

File

src/Plugin/WebformElementBase.php, line 1177

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

public static function preRenderFixFlexboxWrapper(array $element) {

  // Allow Ajax callbacks to disable flexbox wrapper.
  // @see \Drupal\webform\Element\WebformComputedBase::ajaxWebformComputedCallback
  // @see \Drupal\webform\Element\WebformMultiple::ajaxCallback
  if (isset($element['#webform_wrapper']) && $element['#webform_wrapper'] === FALSE) {
    return $element;
  }
  $flex = isset($element['#flex']) ? $element['#flex'] : 1;
  $element += [
    '#prefix' => '',
    '#suffix' => '',
  ];
  $element['#prefix'] = '<div class="webform-flex webform-flex--' . $flex . '"><div class="webform-flex--container">' . $element['#prefix'];
  $element['#suffix'] = $element['#suffix'] . '</div></div>';
  return $element;
}