OS: OSX 10.5.8
Stack: MAMP Version 1.8.4 (1.8.4)
Webserver/PHP name and version: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2
Drupal dev nightly build 03/30/2010
Drupal Path: MAMP/htdocs/drupal-7.x-dev
Note: This is repeatable on drupal-7.0-alpha3
Goal: Term containing comma
Example: Einstein, Albert
Reason: It is common practice in library vocabularies to list last name, first name. This practice is also widely adopted in other fields and for other forms of titles and terms.
To elicit faulty behavior:
Step one - add term to vocabulary
Step two - enter for Name field - "Einstein, Albert"
Step three - click Save
Step four - view response - "Created new term Einstein, Albert."
Step five - click List tab
Step six - view List tab - There is no entry for "Einstein, Albert"
Step seven - create new content - "Homepage for scientists"
Note: Content type manage fields info:
Label = Scientist
Name = field_scientist
Field = Term reference
Widget = Autocomplete term widget (tagging)
Step eight - fill out all required fields and enter into field Scientist = "Einstein, Albert"
Step nine - click Save
Step ten - view response - "Scientist: this field cannot hold more than 1 values."
Note one: In an non-repeatable instance, it worked. However, no other attempts have succeeded.
Note two: Behavior is identical when also adding a description to taxonomy in step two.
Comment | File | Size | Author |
---|---|---|---|
#22 | Screen Shot 2021-07-01 at 9.35.26 PM.png | 11.03 KB | pameeela |
#11 | 758992-8.patch | 1.22 KB | mgifford |
#8 | 758992-8.patch | 1.22 KB | amateescu |
#5 | taxonomy-respectcardinality-758992.patch | 915 bytes | magnusk |
Comments
Comment #1
worldlinemine CreditAttribution: worldlinemine commentedAdditional information:
I was able to reproduce "Note one: In an non-repeatable instance, it worked. However, no other attempts have succeeded." and thus have a poor work around.
Work around:
After creating a non-comma delimited term (ie. Name = Einstein), upon editing of the term it is possible to switch it to (ie. Name = Einstein, Albert).
Negative consequence:
The term is no longer searchable via Widget = Autocomplete term widget (tagging).
The term also no longer appears in vocabulary lists.
Conclusion:
A coded fix to handle terms with commas would be desirable.
Note:
Oddly enough terms like: Name = "Einstein. Albert" and Name = "Einstein: Albert" do work, so I suspect comma is being used internally for taxonomy.module
Comment #2
mr.baileysYou can surround taxonomy terms with quotes. So Apple, Banana, "Einstein, Albert" should create 3 terms, not 4.
Comment #3
worldlinemine CreditAttribution: worldlinemine commentedThank you very much for that info.
Several things to note:
The term is still not searchable via Widget = Autocomplete term widget (tagging).
However, the term does appear in the proper vocabulary list.
The term also can be reused, so if one uses "Einstein, Albert" for two or more different nodes even though auto-complete can't find the term it does show up as linked to the same term after saving the new node rather then attempting to create the term multiple times.
Comment #4
mr.baileysCorrect, there is a problem with autocompletion of quoted terms. There already is an issue open for that though, #321080: Usage of Quotes in tag in combination with taxonomy_autocomplete, so it's probably best to continue the discussion there. If you are comfortable applying patches, you might want to test the patch offered there and provide feedback to move that issue forward.
Comment #5
magnusk CreditAttribution: magnusk commentedThis issue is not a duplicate of autocompletion with quoted terms.
Problem: If a taxonomy field has single cardinality there is an incorrect autocomplete validation if the term name happens to contain a comma. The error message is very confusing for regular people who enter content on a Drupal site.
Correct behavior: The term name should be accepted as is, but the validation in taxonomy_autocomplete_validate() incorrectly assumes that the value is a comma separated list of terms. This is only true if the cardinality of the field is greater than one.
Proposed solutionL I'm attaching a proposed patch, calling drupal_explode_tags() only if the field cardinality is greater than 1.
Comment #6
andypost@magnusk please provide a patch in unified format
also this should be fixed in 8 first
Comment #7
jibranAfter #1847596: Remove Taxonomy term reference field in favor of Entity reference taxonomy field is converted to ER field. If this problem exists then it's a common problem so moving it to ER queue. Marking it postpone (maintainer needs more info) because we want to verify if there is still a problem or not.
Comment #8
amateescu CreditAttribution: amateescu commentedI think this is all we need to fix the problem but we need to confirm that with some manual testing.
Comment #9
jibranIt could also use some Web Tests.
Comment #10
amateescu CreditAttribution: amateescu commentedSo the fix is not so simple because
Drupal\system\Controller\EntityAutocompleteController::handleAutocomplete()
also splits the string unconditionally withTags::explode()
.Anyway, the test for this should probably be added at the bottom of
Drupal\system\Tests\Entity\EntityAutocompleteTest::testEntityReferenceAutocompletion()
.Comment #11
mgiffordRe-uploading #8 for the bots.
Comment #15
jibranMoving to right component
Comment #22
pameeela CreditAttribution: pameeela commentedCan't reproduce this, guessing since it was converted to ER. I've tried the steps in the IS and every way I could think of but it adds quotes and always works for terms with a comma.
If anyone has updated steps please add them to the issue summary and re-open this.