From ceeb3f88c127103c66d4eedb9752a817d60433be Mon Sep 17 00:00:00 2001 From: kenorb Date: Wed, 23 Aug 2017 23:00:31 +0100 Subject: [PATCH] Issue #2901761 by kenorb: Computed field fails to render a form in block --- src/Element/WebformComputedBase.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/Element/WebformComputedBase.php b/src/Element/WebformComputedBase.php index 5d934279..50000f95 100644 --- a/src/Element/WebformComputedBase.php +++ b/src/Element/WebformComputedBase.php @@ -68,17 +68,16 @@ abstract class WebformComputedBase extends FormElement { public static function processWebformComputed(&$element, FormStateInterface $form_state, &$complete_form) { $webform_submission = static::getWebformSubmission($element, $form_state); if ($webform_submission) { - $value = static::processValue($element, $webform_submission);; // Display markup. - $element['value']['#markup'] = $value; + $element['value']['#children'] = $element['#value']; // Include hidden element so that computed value will be available to // conditions (#states). $element['#tree'] = TRUE; $element['hidden'] = [ '#type' => 'hidden', - '#value' => ['#markup' => $value], + '#value' => ['#markup' => $element['#value']], '#parents' => $element['#parents'], ]; @@ -94,21 +93,6 @@ abstract class WebformComputedBase extends FormElement { return $element; } - /** - * Process computed value. - * - * @param array $element - * The element. - * @param \Drupal\webform\WebformSubmissionInterface $webform_submission - * A webform submission. - * - * @return array|string - * The string with tokens replaced. - */ - public static function processValue(array $element, WebformSubmissionInterface $webform_submission) { - return $element['#value']; - } - /** * Get an element's value mode/type. * -- 2.14.1