Problem/Motivation
Similar to #3587776: Support all entity types but I am missing support for block_content entities.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | canvas_140.png | 23.44 KB | peter törnstrand |
| #6 | canvas_133.png | 22.12 KB | peter törnstrand |
Issue fork canvas_entity_reference-3590586
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
peter törnstrand commentedFirst run at this. Also updated the documentation in
README.md.Comment #4
peter törnstrand commentedI'm missing something, getting the value
entity:node/1in the autocomplete widget after selecting a match. Had it working an hour ago.Comment #5
peter törnstrand commentedComment #6
peter törnstrand commentedI figured it out. I was running version 1.3.3 of the Canvas module in my first environment where I tested this.
When creating the MR in a different environment I was on version 1.4.0. It seems the 1.4.x version of Canvas breaks all types of reference fields defined by this module. Instead of returning the label for the entity an URI is returned, for example
entity:node/1and this does not get processed correctly in the UI.So I guess it has something to do with the normalization of the selected autocomplete value back to the scalar integer expected by the Canvas prop.
Comment #7
peter törnstrand commentedComment #8
zeeshan_khan commentedThanks for the contribution @peter tornstrand! The approach is correct — adding block_content to REF_URI_TO_ENTITY_TYPE, updating schema.json, and adding a matches test is exactly the right pattern.
A few things to fix before we can merge:
1. The Twig template test-block-content-id.twig has copy-paste errors from the
node-id component — it still references article_id, the badge shows
x-entity-field: nid, and the heading says "Node Reference". These should all
be updated to reflect block_id and block_content.
2. It would be good to add a testApplyBlockContentEntityType() kernel test
alongside the matches test, to verify the handler settings and label key
resolve correctly for block_content (the label key is info).
3. Please also double-check whether the block module needs to be listed in
$modules in the test — block_content may be self-sufficient without it.
Comment #9
zeeshan_khan commentedThanks @peter tornstrand! The approach is correct. I've pushed a follow-up commit to your branch fixing the copy-paste errors in the Twig template (article_id -> block_id, wrong badge text, heading, and CSS modifier class) and adding testApplyBlockContentEntityType() to verify the handler settings and label key (info) resolve correctly for block_content.
Comment #10
kleve commentedThe patch does not apply to the latest version 1.0.3.
Comment #11
zeeshan_khan commented@kleve Thanks for the report. The block_content entity support (including the tests) was merged and released in 1.0.3. Please update your module to 1.0.3 and the feature should be available without needing to apply any patch.
You can update via Composer:
composer require drupal/canvas_entity_reference:^1.0
composer update drupal/canvas_entity_reference
Comment #12
anybodyTahnks @zeeshan_khan - looks like this is fixed then?
Comment #13
zeeshan_khan commentedyes @julian if you can RTBC this one we can close it :) thanks
Comment #14
zeeshan_khan commentedBased on the last comment by @julian marking this to Fixed!
Feel free to re-open or create new issue if the issue persist anymore.
Comment #15
zeeshan_khan commented