You are here

public function ContainerBase::prepare in Webform 6.x

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

Prepare an element to be rendered within a webform.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.

Overrides WebformElementBase::prepare

See also

\Drupal\webform\Element\WebformCompositeBase::processWebformComposite

3 calls to ContainerBase::prepare()
Details::prepare in src/Plugin/WebformElement/Details.php
Prepare an element to be rendered within a webform.
WebformCard::prepare in modules/webform_cards/src/Plugin/WebformElement/WebformCard.php
Prepare an element to be rendered within a webform.
WebformSection::prepare in src/Plugin/WebformElement/WebformSection.php
Prepare an element to be rendered within a webform.
3 methods override ContainerBase::prepare()
Details::prepare in src/Plugin/WebformElement/Details.php
Prepare an element to be rendered within a webform.
WebformCard::prepare in modules/webform_cards/src/Plugin/WebformElement/WebformCard.php
Prepare an element to be rendered within a webform.
WebformSection::prepare in src/Plugin/WebformElement/WebformSection.php
Prepare an element to be rendered within a webform.

File

src/Plugin/WebformElement/ContainerBase.php, line 65

Class

ContainerBase
Provides a base 'container' class.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
  parent::prepare($element, $webform_submission);
  if (!empty($element['#randomize'])) {
    $elements = [];
    foreach (Element::children($element) as $child_key) {
      $elements[$child_key] = $element[$child_key];
      unset($element[$child_key]);
    }
    $element += WebformElementHelper::randomize($elements);
  }
}