Problem/Motivation
Follow-up to #2317797: Comma in string (non-delimiter) creates multiple terms - see #10 for 7.x-2.2
According to the release notes, terms with commas are supported since 7.x-2.0-beta1 and the delimiter can be configured since 7.x-2.0-beta3.
I have found this is not true, when adding terms via Autocomplete Deluxe.
With the delimiter configured to be ";", entering a new string "Lorem Ipsum, Dolor" will show as a single tag in the UI, but when looking at the term list, 2 terms have been added: "Lorem Ipsum" and "Dolor".
![]()
Proposed resolution
Rework autocomplete validation to use custom static function that imitates Drupal\Component\Utility\Tags::explode but uses delimiter that we specify in the form element. This way it works for new and existing terms.
Remaining tasks
- ✅ File an issue
- ✅ Addition/Change/Update/Fix
- ➖ Testing to ensure no regression
- ➖ Automated unit testing coverage
- ➖ Automated functional testing coverage
- ➖ UX/UI designer responsibilities
- ➖ Readability
- ➖ Accessibility
- ➖ Performance
- ➖ Security
- ➖ Documentation
- ✅ Code review by maintainers
- ➖ Full testing and approval
- ✅ Credit contributors
- ✅ Review with the product owner
- ✅ Release notes snippet
- ✅ Release autocomplete_deluxe-2.0.4
API changes
- N/A
Data model changes
- N/A
Release notes snippet
- Issue #2903968: Fixed comma in string (non-delimiter) creates multiple terms
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | delimiter_issue-2903968-7.patch | 9.56 KB | sickness29 |
| #6 | autocomplete_comma-2903968-2.patch | 1.83 KB | garypigott39 |
| #4 | autocomplete_comma-2903968-1.patch | 1.25 KB | manuga |
Issue fork autocomplete_deluxe-2903968
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 #2
ataimist commentedOnly a single term is created if the tag name containing commas is quoted (though this displays incorrectly in the UI as < The term ""tag, name"" will be added >, it will be created correctly as a single term with the comma in place and without the extra quotation marks).
Seems like this might be what Tags::explode(), which is used in AutocompleteDeluxeController::handleAutocomplete(), expects to be done for such tags. Didn't yet manage to figure out where to do it, though.
Comment #3
jweakley commentedIs it possible to have a choice as a user of this module if I want to have the values of a taxonomy term reference field be considered as having quotes around it or not? Why can't it be the default to just treat all characters in this field as being wrapper in quotes?
Comment #4
manuga commentedPossible solution
Comment #5
rajab natshahComment #6
garypigott39 commentedSo, that didnt work for me as it was losing some of the added tags in a multi-value field. I reworked it slightly and have attached the version that works for me in case it's of any use to someone.
Comment #7
sickness29 commentedI have reworked autocomplete validation to use custom static function that imitates Drupal\Component\Utility\Tags::explode but uses delimiter that we specify in the form element. This way it works for new and existing terms.
Comment #8
sickness29 commentedComment #11
sickness29 commentedComment #13
rajab natshahComment #14
rajab natshahComment #15
rajab natshahComment #17
rajab natshahThanks, Andrew, for following on this issue.
Better to keep using the Drupal Core Autocomplete Validator to work with Drupal 10 and Drupal 11
Having custom validator will bring more issues ( reverted )
Committing the patch from #6 by Gary
Comment #19
rajab natshahComment #20
rajab natshah✅ Released autocomplete_deluxe-2.0.4