How to disable creating new tags with select2 v4.0?
I've been struggling with this as well, but got it working after a few hours.
I had specified a few token seperators (because my visitors are allowed to create tags in a different spot in the website). Turns out the seperators are still applied even if the tags
configuration is set to false
.
Solution: tags: false
and do NOT add a value for tokenSeperators
. Keep multiple: true
.
You can disable tags by removing tags: true
when initializing Select2. Or alternatively, setting tags: false
when initializing Select2. Tags are only enabled if the tags
option is truthy, which it is when you are passing in true
.
This should work - in the initialization of select2, try returning undefined from the createTag function like so:
createTag: function(params) {
return undefined;
}