You are here

public static function WebformElementBase::preRenderFixStatesWrapper in Webform 8.5

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

Fix state wrapper.

Notes:

  • Certain elements don't support #states so a workaround is to adds a wrapper that renders the #states in a #prefix and #suffix div tag.
  • Composite elements tend not to properly handle #states.
  • Composite elements need propagate a visible/hidden #states to sub-element required #state.

Parameters

array $element: An element.

Return value

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

File

src/Plugin/WebformElementBase.php, line 1156

Class

WebformElementBase
Provides a base class for a webform element.

Namespace

Drupal\webform\Plugin

Code

public static function preRenderFixStatesWrapper(array $element) {

  // Allow Ajax callbacks to disable states wrapper.
  // @see \Drupal\webform\Element\WebformComputedBase::ajaxWebformComputedCallback
  // @see \Drupal\webform\Element\WebformMultiple::ajaxCallback
  if (isset($element['#webform_wrapper']) && $element['#webform_wrapper'] === FALSE) {
    return $element;
  }
  WebformElementHelper::fixStatesWrapper($element);
  return $element;
}