Closed (fixed)
Project:
Canvas Entity Reference
Version:
1.0.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 May 2026 at 11:14 UTC
Updated:
25 May 2026 at 18:00 UTC
Jump to comment: Most recent
Comments
Comment #2
anybodyI guess it's the
target_idthat would be helpful to expose to the SDC. I agree that there are cases where you for example need to get additional information from the term (e.g. through twig_tweak) where that would be super helpful! I'm also interested if that's possible!Comment #3
anybodyI guess we'd need to make
https://git.drupalcode.org/project/canvas_entity_reference/-/blob/1.0.x/...
configurable per component or in the general settings?
For example to return the TID instead of the name it might be
is that correct?
Is it also possible to pass multiple values to the SDC?
Otherwise at least being able to set which property it should return (with tid as most flexible one) would be great!
Comment #5
thomas.frobieterpublic const PROP_EXPRESSION = "ℹ︎entity_reference␟entity␜␜entity:taxonomy_term␝tid␞␟value";Yes, just tested and I get the TID instead the term name.
Comment #6
anybodyWe have a similar requirement for images (from Media library): #3588802: How to get the Media ID (target_id) of a Image Object in a SDC? in Canvas itself.
Comment #7
zeeshan_khan commentedThis has been implemented in the
1.0.xbranch.What was done
x-entity-fieldJSON Schema annotation.Component authors can specify which field on the referenced entity is returned
as the prop value.
x-entity-fieldis omitted, the module falls back to theentity type's label key (e.g.
titlefor nodes,namefor taxonomy terms and users).
type: array)props — the annotation can be placed on the root schema or on
items.Usage examples
Return the node title (default, no annotation needed):
article: type: string x-entity-type: nodeReturn the numeric node ID instead:
article_id: type: integer x-entity-type: node x-entity-field: nidReturn a taxonomy term's
tidinstead of its name:tag_id: type: integer x-entity-type: taxonomy_term x-entity-field: tidThe annotation can reference any field machine name available on the entity
type. The schema
typeshould match what the field value actuallyreturns (e.g.
integerfor ID fields,stringfortext fields).
@anybody @thomas.frobieter - I have added new release with all the changes 1.0.1
Comment #8
zeeshan_khan commentedComment #10
anybodyThank you @zeeshan_khan - that looks great and very flexible!
Some ideas:
1. In https://git.drupalcode.org/project/canvas_entity_reference/-/blob/1.0.x/... you should log an error and not mute it entirely, so administrators are able to find such errors and fix it! A helpful error message would be great for the logs.
2. I guess same should be done in https://git.drupalcode.org/project/canvas_entity_reference/-/blob/1.0.x/... with at least a warning or notice, because otherwise if the
isset(EntityReferenceConstants::REF_URI_TO_ENTITY_TYPE[$items_ref])is false, it will silenty proceed?3. Are there other places like this, where logging an error or warning similarly makes sense for DX?
4. The documentation on the module page / README should be updated to reflect the new possibilities? Maybe after #3588752: Allow using other entity widgets and also contrib widgets on entity_reference (Tagify, Entity Browser, ...) is also resolved?
Comment #11
zeeshan_khan commentedThanks for the suggestions - below are the answers to your questions
Some ideas:
1. In https://git.drupalcode.org/project/canvas_entity_reference/-/blob/1.0.x/... you should log an error and not mute it entirely, so administrators are able to find such errors and fix it! A helpful error message would be great for the logs.
Ans - Will fix in upcoming release
2. I guess same should be done in https://git.drupalcode.org/project/canvas_entity_reference/-/blob/1.0.x/... with at least a warning or notice, because otherwise if the isset(EntityReferenceConstants::REF_URI_TO_ENTITY_TYPE[$items_ref]) is false, it will silenty proceed?
Ans - Will fix in upcoming release
3. Are there other places like this, where logging an error or warning similarly makes sense for DX?
Ans - I couldn't find any - please let me know if you find any.
4. The documentation on the module page / README should be updated to reflect the new possibilities? Maybe after #3588752: Allow using other entity widgets and also contrib widgets on entity_reference (Tagify, Entity Browser, ...) is also resolved?
Ans - #3588752 - already resolved
I did modify documentation a bit on module's page but forgot to update Readme.md will do that soon
Thanks again!
Comment #12
anybodyThank you @zeeshan_khan! Let me know when ready and leave the commit here, then I'll review the changes.
Didn't find further places yet either.
Comment #13
zeeshan_khan commented(Note: All changes live in dev release).
Addressed all the feedback points:
Comment #14
zeeshan_khan commentedComment #15
anybodyPS: Another benefit of MRs is that we can comment them in GitLab, which makes reviews and communication easier.
One suggestion:
At
'Canvas Entity Reference: could not resolve label key for entity type "@type": @message'you could add "Falling back to "name" property." or something like that to also tell what happened in result :)Comment #17
anybodyComment #18
zeeshan_khan commentedMR https://git.drupalcode.org/project/canvas_entity_reference/-/merge_reque...
Good suggestion — updated the error message to:
Canvas Entity Reference: could not resolve label key for entity type "@type": @message Falling back to "name" property.
Administrators can now see both what failed and what the module did as a result, without needing to look at the source. Also noted your point about MRs — !4 is already open for this branch and future work will use MRs where possible.
Comment #19
zeeshan_khan commented