Closed (fixed)
Project:
Canvas Entity Reference
Version:
1.0.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Apr 2026 at 05:49 UTC
Updated:
25 May 2026 at 18:00 UTC
Jump to comment: Most recent
Comments
Comment #2
zeeshan_khan commentedThanks for pointing this out — that’s a fair observation.
Currently, the module supports taxonomy term entity references only, as that was the initial use case for integrating with the Canvas component props system.
However, the module is designed with extensibility in mind, and support for additional entity types (e.g., nodes, media, custom entities) is definitely planned for future iterations.
The current naming reflects the broader goal,
Comment #3
anybodyThanks for the rapid feedback! Would be great to not support them one by one, but hopefully being able to use the abstraction level of entity types / entities. I guess modules like entity_reference or dynamic_entity_reference do the same.
Great work, thank you!! :)
Comment #4
zeeshan_khan commentedThanks, really appreciate the feedback 🙂
Yes — I completely agree. The goal is not to add support for entity types one by one, but to move toward a more generic approach based on Drupal’s entity API.
The current taxonomy term support is just the first step, but the plan is to leverage the abstraction around EntityInterface / EntityTypeManager so this can work across different entity types in a consistent way — similar in spirit to what entity_reference and dynamic_entity_reference provide.
I’m currently exploring how best to generalize the data transformation layer for Canvas props without introducing too much complexity.
Thanks again for the suggestion — it definitely aligns with the direction I want to take this module.
Comment #5
anybody@zeeshan_khan thanks, that sounds promising and exciting!
Are you aware of #3573831: [META] Code Components: add an "content entity reference" prop type — enables "view modes" that combine multiple entities plus static inputs!? Should that maybe get linked on the module page?
Comment #6
zeeshan_khan commentedYes, thanks for pointing this out.
This module explores similar ideas around passing entity references into component-based rendering (via Canvas/SDC), especially for composing structured outputs from multiple sources.
While it doesn’t implement that proposal directly, there’s clear overlap in goals and approach. Linking it as related work on the module page makes sense and could help provide useful context for where this pattern is heading.
Happy to add a reference there.
Comment #7
thomas.frobieter@zeeshan_khan Do you have a rough timeline in mind? Sorry, I don't mean to rush you, but this is just such an important feature for Canvas that we really miss 😩
Comment #8
anybodyEdit: sorry wrong issue!
Comment #9
zeeshan_khan commented@thomas.frobieter - I'm thinking to work on it this weekend if that works?
I'll try to wrap it up asap you'll get the updated release by next week.
Comment #10
thomas.frobieter@zeeshan_khan Thats awesome! Thank you :)
Comment #11
anybodyVery nice @zeeshan_khan very much looking forward to that!
BTW you might want to add https://www.drupal.org/project/entity_block as alternative to the module page. We found that a helpful workaround for other entity types for now.
It's no replacement because these native components have several benefits, but may also help other users and for other cases! With that module you're able to place any entities in the selected view mode in canvas using blocks!
Comment #12
zeeshan_khan commentedThis has been implemented in the
1.0.xbranch.What was done
x-entity-typeJSON Schema annotation. Componentauthors can now declare any entity type instead of being locked to taxonomy
terms.
$refdefinitions toschema.json:taxonomy-term-reference,node-reference,user-reference, andmedia-reference. These can be used directly via$refor matched automatically from
x-entity-type.EntityReferenceShapeMatcherto recognise all entitytypes via both the legacy
$refURI and the newx-entity-typeannotation, including array props (with
items.x-entity-type).default:{entity_type}) and propexpression are now built dynamically for each entity type.
drupal:taxonomymodule dependency —the module now works with any installed entity type.
Usage examples
Single node reference (returns the node title):
my_article: type: string x-entity-type: nodeSingle user reference using the built-in
$ref:author: $ref: 'json-schema-definitions://canvas_entity_reference.module/user-reference'Multi-value media reference:
gallery: type: array items: type: string x-entity-type: mediaBundle restrictions and auto-create remain supported for
taxonomy_term. All other entity types use the default handlerwith no bundle restrictions.
Additionally, a
Twig function is provided so component templates can render
the full entity output (e.g. a media image) when needed.
Also added 5 new Test SDCs for each
@anybody @thomas.frobieter - I have added new release with all the changes 1.0.1
Comment #13
zeeshan_khan commentedComment #14
anybodyGREAT work @zeeshan_khan! Sorry my comment is overlapping a bit across issues, see https://www.drupal.org/project/canvas_entity_reference/issues/3588651#co...
I also think you should review the final implementation for possible security issues. While I think access to the schema is needed to do bad things maybe, if a validation is missing somewhere?
Anything else we might have missed you've been thinking about?
Really awesome work, thank you for addressing our initial feedback that fast!
Comment #15
zeeshan_khan commentedThanks for quick response and feedbacks
I'll double check on your latest comment questions!
Comment #16
anybodyThanks. Afterwards I'd say this is fixed then for now! :)
Comment #17
zeeshan_khan commented(Note: all the changes currently lives in dev release)
Completed a security review of the implementation. Three issues were found and fixed:
No other security concerns were found in the current implementation. The schema annotations (x-entity-type, x-entity-field, etc.) are defined in component YAML files which require file system access to modify, so those are not an attack surface.
Comment #18
zeeshan_khan commentedComment #19
anybody@zeeshan_khan whao great findings! What about the autocomplete widget results shown to the user - are they already checked for access somewhere in the widget?
We should ensure not exposing information there, for example if someone enters the name of a taxonomy term that is not accessible to him? (Didn't check that yet)
Comment #20
anybodyPS Would be great if you could link the related commits at least or use a commit message that references the issue (see the suggestion in the link below for the contribution record: https://new.drupal.org/contribution-record?source_link=https%3A//www.dru...) that will make reviews much easier! :)
(Or even better use MR's where possible - but of course I got your reasons!).
Comment #22
zeeshan_khan commentedMR https://git.drupalcode.org/project/canvas_entity_reference/-/merge_reque...
#19
Yes, the autocomplete suggestions are already access-controlled by Drupal core. This module sets handler: "default:{entity_type}" for all entity types, which uses Drupal's built-in DefaultSelection handler. That handler runs entity queries with access checks enabled, so users will only see entities they are allowed to view in the autocomplete results — unpublished nodes, restricted media, or private terms will not appear for users without the appropriate permissions.
#20
Good point — going forward all commits will reference the relevant issue number in the format Issue #XXXXXXX by zeeshan_khan: description for proper contribution record tracking. The existing commits on this branch predate that, but new work will follow the convention. An MR is already open for this branch at !4.
Comment #23
anybodyPERFECT (I think)! :)
Comment #24
zeeshan_khan commented