I am using select2 as my multiple input textbox as follows
<input name="locations[]" class="width_100" id="locations" type="text" placeholder="London, Delhi.." >
My initialisation part in js as follows
$("#locations").select2({
minimumInputLength: 3,
tags: [],
ajax: {
url: $('#site').val()+'/ajax/location_search/'+Math.random(),
dataType: 'json',
type: "GET",
quietMillis: 50,
data: function (term) {
return {
term: term
};
},
results: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.city_name,
id: item.city_id
}
})
};
}
}
});
In all other select2 fileds are getting as an array in the backend. But in this I am getting the input as comma separated values like the following
[locations] => Array
(
[0] => 17633,35799
)
The same select2 multiple, but not the ajax one giving the data as array as follows
[languages] => Array
(
[0] => 7
[1] => 1
)
Can any one please help to to solve the issue ?
Aucun commentaire:
Enregistrer un commentaire