When previewing a not saved yet node in a view mode that uses a Link field group linked to the entity URL, the following error is thrown:

The "node" entity cannot have a URI as it does not have an ID

This is totally expected since the Link field group formatter code retrieve the URL of the entity while the entity doesn't have an id yet and thus doesn't have an URI.

CommentFileSizeAuthor
#6 3256228-3.patch799 bytesleon kessler
#2 2985999.patch698 byteseric morand

Comments

Eric MORAND created an issue. See original summary.

eric morand’s picture

StatusFileSize
new698 bytes
leon kessler’s picture

Status: Active » Needs review
chaloum’s picture

A similar issue to what I'm having. having an ID is perfectly fine but the ID field should allow tokens so you can do something like node-[node:nid]

this becomes important especially if you are rendering out nodes in a view mode using Views. The way it is ATM on a page, each returned record has the same ID

gngn’s picture

Same problem here:

  • preview with view mode "teaser"
  • "teaser" has checked "Linked to node page"
  • without module field_group_link
  • module field_group is enabled (and used in view mode "teaser"

It works if I uncheck "Linked to node page" in the "teaser" view mode - but I really like to link he teaser to the node...

Any ideas?

leon kessler’s picture

Priority: Critical » Normal
StatusFileSize
new799 bytes

Adding a new patch that uses $entity->isNew() (instead of checking for the id). There isn't really much difference, but looking through other code in core, using if(!$entity->isNew()) is used in few places to check whether a url can be created for an entity, so following these as best practises.

Also, I would not consider this to be a critical issue. It only effects the preview mode, which not all sites use, and most only allow admin roles to use this functionality.

As previously stated, there is no way we can generate a url for an entity that is not yet created. The patch from this issue will mean the field group is simply not rendered, so won't cause an error. We could possibly look at generating a "dummy" url in this scenario, so that the preview still looks like it should. But I am a bit reluctant to add in a feature like that, and would not have time to write and test it.

@chaloum I don't fully understand your issue, but it sounds more related to views then preview. Please could you open this in a separate issue?

  • Leon Kessler authored fcd0184 on 8.x-3.x
    Issue #2985999 by Eric MORAND, Leon Kessler: The "node" entity cannot...
leon kessler’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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