select2/select2
View on GitHubCreating a new tag with a value equal to the id of an existing option causes both the new tag and the existing option to be added as selections
Open
#3498 opened on Jun 19, 2015
4.xconfirmed bugfeature: multi-selectfeature: selectionsfeature: tagginghelp wanted
Description
// input: red,
// var_dump($_POST["colors"]);
Array
(
[0] => red
[1] => red
)
// input: apple,green,water,
// var_dump($_POST["colors"]);
Array
(
[0] => green
[1] => green
)
// input: red,green,blue,yellow,
// var_dump($_POST["colors"]);
Array
(
[0] => red
[1] => green
[2] => blue
[3] => yellow
[4] => red
)
<select name="colors[]" id="tags-example" multiple="multiple">
<option value="red">apple</option>
<option value="green">grass</option>
<option value="blue">water</option>
<option value="yellow">sun</option>
</select>
$('#tags-example').select2({
tags: true,
tokenSeparators: [',', ' '],
maximumSelectionLength: 2
});
Please see the following fiddle to see what happens: http://jsfiddle.net/o1je0988/