Problem/Motivation
In Drupal 7, if I create a field on a content type, I am able to reuse that field for a taxonomy vocabulary.
In Drupal 8, this is not possible. I can only reuse taxonomy fields that I have already created for another taxonomy vocabulary, and content type fields that I have already created for another content type.
This is contrary to the documentation on re-using fields here:
https://www.drupal.org/docs/8/administering-drupal-8-site/managing-conte...
which states (bold added for emphasis):
Once you have defined a field, you can reuse it. For example: if you define a custom image field for one content type, and you need to have an image field with the same parameters on another content type, you can add the same field to the second content type, in the Add existing field area of the user interface. You could also add this field to a taxonomy vocabulary, comments, user accounts, etc.
I can create a new field for use on a taxonomy vocabulary with the same machine name. In the database, there will now be two tables:
node__field_name
taxonomy_term__field_name
Apologies if this is a duplicate - I couldn't find any other issues that discussed this.
Drupal 8.5.5, observed on multiple sites.
Steps to reproduce
Proposed resolution
Update Reusing fields to correct that field can no longer be shared across entity types.
Remaining tasks
Review
Comments
Comment #2
millionleaves commentedComment #3
johnpitcairn commentedYou're certainly not alone noticing this. I think field definitions are now entity-type specific, whereas in Drupal 7 they were not.
The docs were probably just copied from Drupal 7 and need updating to indicate that in Drupal 8 you can only re-use a field among entities of the same type.
Comment #6
ey commentedI should state that this change really defeats the purpose of re-using fields, or at least drastically reduces the use cases. I am really disappointed to find out that it doesn't work as it was in Drupal 7 and it broke a lot of architectural designs in the concept that we made before starting to do a Drupal 8 upgrade for a big project.
Comment #8
giorgio79 commentedYeah, why even have a separate entity for taxonomy when all the difference is that it provides a nice hiearchy goodies... Taxonomy is easily like any other node entity.
Comment #11
cilefen commentedIs this just a documentation bug?
Comment #12
ey commentedNo, it's not a documentation bug.
Re-using fields between different entity types was possible in D7 and is not working in D8. You cannot, for example, create a field for a content type and reuse the same field on user accounts or taxonomy vocabularies in D8.
Comment #13
johnpitcairn commentedIt's a regression from D7. Was there an explicit reason or decision to couple field storage or instance config to the parent entity type at some point in D8 development?
Comment #14
cilefen commentedComment #15
cilefen commentedI have no idea. I have only observed that this has been open for three years with no answer.
Has anyone following this issue perused the change records of that era? If there is a reason it could be recorded there.
Comment #16
johnpitcairn commentedThanks @cilefen. I remember checking at the time and not finding anything:
https://www.drupal.org/list-changes/drupal/published?keywords_descriptio...
The only change notice mentioning "re-use" is this:
https://www.drupal.org/node/2393181
I can't search issues for keywords with a hyphen (no results), but trying to figure out whether there are issues that covered this during the 7.x-8.x development cycle is beyond me.
Comment #17
xurizaemonHi there
Please see changelog entry https://www.drupal.org/node/2078765 ... I guess "shareable" was the spelling of "re-use" you were looking for?!
This should be remedied in the linked documentation then IMO.
Comment #18
xurizaemonNW for docs update.
Separately - I can't see how to make change record https://www.drupal.org/node/2078765 appear in the change records view. Maybe it's a bad node or something. The linked display ought to have that CR as the fourth listed item, since we're looking at 8.x records starting from just after that date? Same results searching for "bound", "shareable", "massive" etc.
Comment #19
quietone commentedI have updated the wiki page to clarify that sharing field across entity types is no longer possible. I think that covers everything here
I think that some one can review this and mark it fixed if the changes to doc page is sufficient.
Comment #20
lendudeDiscussed this with @quiteone in #bugsmash and the new documentation looks good and in line with what Drupal 8+ actually does.
Thanks for reporting this and the feedback everybody.