Problem/Motivation
The module does not filter unpublished a taxonomy terms from the select list. Unpublished terms are listed in the select list, despite the user role does not have rights to see these terms. If you try to save content with an unpublished term selected it gives an error "This entity (taxonomy_term: 2013) can not be referenced."
Steps to reproduce
Install module on drupal 11 website
Create a taxonomy with several terms (at least one unpublished term
Add one field with type entity reference (taxonomy term) to an content type (lets say "project"
Create new content of type "project" (user must not have admin permissions on taxonomy terms)
Select an unpublished term in the entity reference field
Save content
Content will not be saved and the above mentioned error appears below the field
Proposed resolution
Attached patch taxonomy_container-hide-unpublished-terms.patch
Tested and works for my website.
| Comment | File | Size | Author |
|---|---|---|---|
| taxonomy_container-hide-unpublished-terms.patch | 1.06 KB | saccard |
Comments
Comment #2
dkmishra commentedThanks for the report and the patch, @saccard.
Testing this on a fresh Drupal 11.4 install: as admin, I see both Published and Unpublished terms. As an authenticated user (without administer taxonomy), I only see Published — the unpublished term is already excluded, without the patch applied.
Could you share what permissions your test role had, and whether this still reproduces on a fresh install?
Comment #3
saccard commentedThanks for the quick reply.
Further testing shows that this problem seems to be a side effect from group module. In use is group (3.3.5). The reference field is part of a group content and uses the reference method "Taxonomy terms selection (with groups)". When I change the method to "default" the problem is gone and the user can only see published taxonomy terms. Switching back to "Taxonomy terms selection (with groups)" the problem reappears. With the patch applied it works with both settings.