I know that this module is being maintained rarely, but I appreciate anyone help me on this. When we use any taxonomy term reference elements the analysis result show term IDs instead of term label. It would be great if we could see the labels.

Comments

jshosseini created an issue. See original summary.

sokru’s picture

StatusFileSize
new1.15 KB

Needed this for POC, so I hacked the term name visible. This patch will cause fatal error if Entity select webform_entity_select uses something else than Taxonomy term as type of item.

sokru’s picture

Status: Active » Needs review

Used entityTypeManager so it should in theory work with any entity type. Tested with taxonomy terms and content (node) entities.

sokru’s picture

StatusFileSize
new1.5 KB

And the missing patch.

sokru’s picture

StatusFileSize
new1.04 KB

And the proper missing patch :)

sokru’s picture

jshosseini’s picture

Dear sokru!
Sorry for delayed response :( .
I tested #2 and #5. As you wrote, #2 caused fatal error. But #5 did not worked for me. So I still see term IDs instead of term names with #5.

dsrdigialltd’s picture

StatusFileSize
new1.43 KB
sokru’s picture

Version: 8.x-1.0-beta7 » 8.x-1.x-dev
Status: Needs review » Needs work

@dsrdigialltd thanks for update!

+      if ($value_label != '') {

Should be written as

+      if ($value_label) {
jshosseini’s picture

Thanks for your kind help. But nothing changed in output. Term Ids still are shown instead of term labels.

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new1.47 KB
new765 bytes

Adding additional cases based on webform field type.
Let's see how it works for use cases.

chandeepkhosa’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new181.41 KB
new212.86 KB

Patches in #5 & #8 also failed for me.
Thanks Mohit, I can confirm your patch in #11 fixes my problem, I am using the Entity Select component.

Before
before

After
before

nevergone’s picture

StatusFileSize
new1.51 KB
new348 bytes

Re-rolled #11 patch with webform_entity_radios support.

llewellyn.dawson’s picture

Assigned: Unassigned » llewellyn.dawson
llewellyn.dawson’s picture

Assigned: llewellyn.dawson » Unassigned
Status: Reviewed & tested by the community » Needs work
StatusFileSize
new40.23 KB

Tested the patch and did not work as intended.

Returns no term fields.

batigolix’s picture

Issue tags: +finalist-sprint
esthertempel’s picture

StatusFileSize
new177.69 KB

I tested both #11 patch and #13 patch on a Drupal 10.2 clean installation with webforms version 6.2.
What I noticed is that if you choose webform_entity_checkboxes, webform_entity_select and/or webform_entity_radios (this last one is added in patch #13) the label of the terms are correctly displayed.

However if you choose webform_term_select the values are empty, nothing is displayed.
And if you choose for instance webform_term_checkboxes (this element is not added in the patches) the ID is displayed instead of the label.

What I notices while debugging is that webform_term_select skips this part of the code:

if (isset($value) && !empty($value)) {
            if (isset($this->getElements()[$component]['#target_type'])) {
              $target_type = $this->getElements()[$component]['#target_type'];
              $entity_storage = \Drupal::entityTypeManager()->getStorage($target_type);
              $entity = $entity_storage->load($value);
              if (is_object($entity)) {
                $value_label = $entity->label();
              }
            }
          }
batigolix’s picture

Status: Needs work » Needs review
StatusFileSize
new2.54 KB

Here is a new patch that also adds labels for Term select and Term checkbox elements.

batigolix’s picture

StatusFileSize
new2.48 KB

Here is a new patch rerolled after the PHPCS fixes

ross.rvt’s picture

Status: Needs review » Reviewed & tested by the community

It works proper

  • 38fe7368 committed on 8.x-1.x
    Issue #3137260 by sokru, batigolix, mohit_aghera, nevergone,...
batigolix’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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