Impact

My solution listed in #2853164: Hierarchical entity select for select with Option Groups no longer works.

Problem

This code change in Drupal\webform\Element\WebformEntityTrait is causing the select element to return blank and throw errors:

Warning: html_entity_decode() expects parameter 1 to be string, array given in Drupal\Component\Utility\Html::decodeEntities() (line 383 of core/lib/Drupal/Component/Utility/Html.php).:

Error-causing code:

    // Issue #2826451: TermSelection returning HTML characters in select list.
    foreach ($options as $key => $value) {
      $options[$key] = Html::decodeEntities($value);
    }

Here is a screenshot of $value being passed to Html::decodeEntities()

Possible solution

When I comment these lines of code, the optgroups is displayed correctly (albeit still with a dash prefix on every term).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ptsimard created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
FileSize
2.25 KB

@ptsimard Please test the attached patch.

ptsimard’s picture

Hey thanks a lot for the amazingly fast fix. It seems to be working fine!

jrockowitz’s picture

No problem. I am trying to keep the simple things... simple and trying to make the complex things... simple.

Fixing this was pretty simple.

  • jrockowitz committed 8abb4d3 on 8.x-5.x
    Issue #2857413 by jrockowitz, ptsimard: Entity select with optgroup no...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.