You are here

public function WebformComposite::finalize in Webform Composite Tools 8

Finalize 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::finalize

See also

\Drupal\webform\Element\WebformCompositeBase::processWebformComposite

File

src/Plugin/WebformElement/WebformComposite.php, line 71

Class

WebformComposite
Provides an Global Composite base.

Namespace

Drupal\webform_composite\Plugin\WebformElement

Code

public function finalize(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
  parent::finalize($element, $webform_submission);

  // Strip the derivative of elements that are not multi valued.
  if ($element['#type'] === $this
    ->getPluginId()) {
    $base_id = $this
      ->getBaseId();
    $element['#type'] = $base_id;
    $element['#' . $base_id] = $this
      ->getPluginId();
  }
  elseif ($element['#type'] === 'webform_multiple' && empty($element['#multiple__header'])) {
    if (isset($element['#element']['#type']) && $element['#element']['#type'] === $this
      ->getPluginId()) {
      $base_id = $this
        ->getBaseId();
      $element['#element']['#type'] = $base_id;
      $element['#element']['#' . $base_id] = $this
        ->getPluginId();
    }
  }
}