1

I use Drupal 8 and I have a content type which has a field that references another content type as a entity reference field. I use a rest endpoint to create the node and the referenced node which works fine.

I also have the workbench module installed so I can change the moderation state of the nodes.

The problem is that when I change the moderation state from draft to review I get the error This entity (node: {ID}) cannot be referenced.

Why am I getting this?

1

The view_unpublished "module allows you to grant access for specific user roles to view unpublished nodes of a specific type. Access control is quite granular in this regard."

composer require drupal/view_unpublished
drush en -y view_unpublished

At /admin/people/permissions set permissions as required:

Permissions page showing content type access for certain roles

Finally, at /en/admin/reports/status/rebuild rebuild the permissions, which may take some time:

Progress bar showing rebuilding of permissions

0

The issue was that the field was used to reference unpublished nodes and kept throwing the error. I updated the field to allow unpublished nodes too. It worked.

  • Where exactly did you update the field to allow unpublished content as well? – Hugo Aug 30 '17 at 10:38
  • In the drupal menu select structure and then content type. Select the content type in question and about half way down he page there is a option selection box. In that box you select unpublished – harnamc Aug 30 '17 at 12:02
  • I must be missing it, here's what I see at /admin/structure/types/manage/article: i.stack.imgur.com/3qCgH.png Please could include a screenshot? – Hugo Aug 30 '17 at 12:34
  • drupal.org/files/issues/field_settings_0.png it's the option that says default. Change that to unpublished – harnamc Aug 30 '17 at 13:50
  • I only see "Default" and "Views: Filter by an entity reference view": i.stack.imgur.com/zBzPm.png I've found another way, which I'll post as an answer. – Hugo Aug 31 '17 at 6:33
0

The views_unpublished module (from this answer) has an ominous bug for multilingual sites and translations with different published status.

An alternative is to use a patch from 'Move permission "view any unpublished content" from content moderation to core: this is something which is currently targeting Drupal Core 8.5. At the time of writing, I've used this patch in Drupal 8.3.7.

0

I was getting this when the Manage fields > Reference Type wasn't set. There are 2 kinds of reference: Reference method and Content type and it is possible to not select anything here - selecting the correct content type solved the issue for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.