diff --git a/src/Element/WebformEntityTrait.php b/src/Element/WebformEntityTrait.php index 3aa95258..b3a0dd24 100644 --- a/src/Element/WebformEntityTrait.php +++ b/src/Element/WebformEntityTrait.php @@ -4,6 +4,7 @@ namespace Drupal\webform\Element; use Drupal\Core\Form\OptGroup; use Drupal\Component\Utility\Html; +use Drupal\webform\Utility\WebformOptionsHelper; /** * Trait for entity reference elements. @@ -61,9 +62,7 @@ trait WebformEntityTrait { } // Issue #2826451: TermSelection returning HTML characters in select list. - foreach ($options as $key => $value) { - $options[$key] = Html::decodeEntities($value); - } + $options = WebformOptionsHelper::decodeOptions($options); $element['#options'] = $options; } diff --git a/src/Utility/WebformOptionsHelper.php b/src/Utility/WebformOptionsHelper.php index 27473232..649e0b3f 100644 --- a/src/Utility/WebformOptionsHelper.php +++ b/src/Utility/WebformOptionsHelper.php @@ -1,6 +1,7 @@ $option_text) { + if (is_array($option_text)) { + $options[$option_value] = self::decodeOptions($option_text); + } + else{ + $options[$option_value] = Html::decodeEntities((string) $option_text); + } + } + return $options; + } + + /** * Build an associative array containing a range of options. * * @param int|string $min