Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The Entity Reference field has two display widgets: "Autocomplete" and "Autocomplete (Tags style)".
Both widgets allow users to add new taxonomy terms to a vocabulary as long as "Create referenced entities if they don't already exist" is enabled on the edit tab of the field. Terms cannot be added if that tick box is not ticked.
Proposed resolution
Since there doesn't seem to be any difference in the functionality of the two widgets "Autocompelete (Tags style)" could be removed.
Comments
Comment #1
ifrikComment #2
BerdirI don't see what the bug here is.
Those widgets do work differently. Try them with cardinality unlimited to see the difference. tag style is "Tag A, Tag B, Tag C", the other one is multiple text fields.
Comment #3
BerdirAn idea I had in IRC is that we could hide the tags style widget when cardinality is 1. We can do that now easily with isApplicable().
Comment #4
ifrikSorry, I see the difference now: the "Autocomplete" widget gives seperate fields in which users can add one term each using autocomplete. That's certainly more usefull if users can add a limited number of terms.
While "Autocomplete (tag style)" is a multitext field. Users can add any numbers of terms, but they got a problem if they add more then the limited number.
And with both widgets it is possible to add new terms if that's enabled.
Then that's more a question of usability:
1) For content creators: If the "Autocomplete" widget is used when the field is limited to one value, then users can't see that, and might just tag by adding several, comma seperated terms - and then get an error message when saving. (It's fine once there are two fields.)
2) Site builders can easily confuse "Autocomplete (Tags style)" with tagging; assuming that that is the widget to choose if you want to allow content creators to add new tags (and overlooking the tickbox for thati in the process). Maybe renaming this widget to somethings like "multi term field (autocomplete)" would solve that.
Comment #7
jibranMoving to right component
Comment #9
xjmRetitling to describe #4.
Comment #11
akshitggrwl CreditAttribution: akshitggrwl commentedWhen using the simple "Autocomplete" widget for multi value reference fields, the widget still allows to enter comma separated list, even though there is "Add another item" button available.
I think comma separated values should not be allowed in this case as the widget only stores the last term in the list of values for that delta.
Comment #13
Joachim NamysloMaybe the difference is that only the last taxonomy term enterd is given to the user instead of a tag style list when viewing the page. I've tried to get a tag style list as in drupal 8.4.x but there is no chance to see more than one taxonomy terme at onece when you viewing the content outside the edit form.
Comment #14
PanchoUI-wise, I would propose turning the “tags style” into a mere widget setting of a single Autocomplete widget, made available only for cardinality≠1. Site builders would be able to choose from “Inline” and “multi-line” widget styles. We need to figure out though, how this would work out DX-wise.
If this route shouldn’t work out well, we should at least hide the Tags-style widget for cardinality=1, as per #3.
We also have to disallow CSV for regular Autocomplete widgets, as per #11. I will however file a separate issue for what actually constitutes a bug.
Comment #15
jibranentity_reference module doesn't have any active code anymore.
Comment #22
MacSim CreditAttribution: MacSim at Spiriit commentedIt could be fun and more user friendly to add a Vanilla input tags script to that "Autocomplete (tags style)"
Something like https://github.com/yairEO/tagify
Comment #24
hmendes CreditAttribution: hmendes at CI&T commentedSome notes:
There's an explanation of the difference between Autocomplete and Autocomplete (Tags style) in /admin/help/field:
The Autocomplete widget displays text fields in which users can type entity labels based on the Allowed number of values. The widget can be configured to display all entities that contain the typed characters or restricted to those starting with those characters.
The Autocomplete (Tags style) widget displays a multi-text field in which users can type in a comma-separated list of entit labels.
About what was said in #4 and #11
1) For content creators: If the "Autocomplete" widget is used when the field is limited to one value, then users can't see that, and might just tag by adding several, comma separated terms - and then get an error message when saving. (It's fine once there are two fields.)
When you have a Taxonomy reference field with cardinality = 1, and Autocomplete(Tags) display, if you try to add more terms after the comma, it will give you an error
taxonomy field: this field cannot hold more than 1 values.
But, if the display is Autocomplete and you try to do the same thing, it won't give an error and will replace the value of the field.
Example:
You have a Taxonomy field and you save it with the term "term1". If you edit the content and try to add the "term2" with comma (so it will be "term1 (1), term2 (2)", it won't give you an error and will save the field with the "term2". (both with cardinality=1 and unlimited)
Should this be the default behavior?
I agree with the comment #14 about turning the Tags styles into a Autocomplete widget setting.
Comment #25
gxleano CreditAttribution: gxleano commented#22 I've already created a module with a Tagify integration to make the autocomplete (tags style) fields more user friendly, you can see it here https://www.drupal.org/project/tagify.
Comment #27
GuyPaddock CreditAttribution: GuyPaddock at Inveniem commentedThoughts:
Comment #30
caspervoogt CreditAttribution: caspervoogt commentedI stumbled across this issue because I was using "Autocomplete (Tags style)" and completely forgot that for multi-value fields the user is supposed to enter commas. The UI does not mention this.