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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3256228-3.patch | 799 bytes | leon kessler |
| #2 | 2985999.patch | 698 bytes | eric morand |
Comments
Comment #2
eric morand commentedComment #3
leon kessler commentedComment #4
chaloum commentedA 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
Comment #5
gngn commentedSame problem here:
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?
Comment #6
leon kessler commentedAdding 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, usingif(!$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?
Comment #8
leon kessler commented