You are here

public function WebformComputedBase::getValue in Webform 6.x

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

Get an element's submission value.

Parameters

array $element: An element.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

array $options: An array of options.

Return value

array|string The element's submission value.

Overrides WebformElementBase::getValue

2 calls to WebformComputedBase::getValue()
WebformComputedBase::formatHtmlItem in src/Plugin/WebformElement/WebformComputedBase.php
Format an element's value as HTML.
WebformComputedBase::formatTextItem in src/Plugin/WebformElement/WebformComputedBase.php
Format an element's value as text.

File

src/Plugin/WebformElement/WebformComputedBase.php, line 117

Class

WebformComputedBase
Provides a base class for 'webform_computed' elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function getValue(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {

  // Get stored value if it is set.
  $value = $webform_submission
    ->getElementData($element['#webform_key']);
  if (isset($value)) {
    return $value;
  }
  return $this
    ->computeValue($element, $webform_submission);
}