у меня есть эта форма
<form class="form-horizontal" action="<?php echo base_url().'C_MRCR_A/generateIBOM'; ?>" method="get">
<div class="box-body">
<div class="form-group">
<label class="col-sm-4 control-label">Select Project</label>
<div class="col-sm-8">
<select id="project-load-modal" class="form-control" name="proj_name" style="width: 100%">
</select>
</div>
</div>
</div>
<!-- /.box-body -->
<button type="submit" class="btn btn-primary">Download</button>
</form>
и эта jquery ajax, чтобы запросить данные select2
$('#project-load-modal').select2({
ajax: {
url: '<?php echo base_url(); ?>index.php/Controller_curl?request=projects-search',
dataType: 'json',
delay: 500,
data: function (params) {
return {
search: params.term,
page: params.page || 1
};
},
processResults: function (res, params) {
var mapped = $.map(res._items, function (obj) {
return {
id: obj._id,
text: obj.project_name
};
});
params.page = params.page || 1;
console.log(mapped);
return {
results: mapped,
pagination: {
more: (params.page * 25) < mapped.total_count
}
};
},
cache: true
},
placeholder: 'Search for a Project',
});
когда я повторяю выбор значение в контроллере я получаю _id
вместо project_name
5e96877bec782d5c26ee414e //this is what i get
5G // this is what i want
это мой контроллер
public function generateIBOM(){
$proj_name = $this->input->get('proj_name');
echo $proj_name;
}
это структура моих json данных
{
"_items": [
{
"_id": "5e996a33004f72344b0d92ee",
"project_name": "BUL PAWS",
"project_year": "2020",
"email_cpm": "",
"email_pp": "",
"fas_1": "",
"fas_2": "",
"fas_3": "",
"fas_4": "",
"created_on": "2020-04-17 16:34:59",
"updated_on": "2020-04-17 16:34:59",
"_etag": "762c71c07e1495b4ef7502d3c2489124bc04fb56"
},
{
"_id": "5e96877bec782d5c26ee414e",
"project_name": "5G",
"project_year": "2020",
"email_cpm": "",
"email_pp": "",
"fas_1": "",
"fas_2": "",
"fas_3": "",
"fas_4": "",
"created_on": "2020-04-15 12:03:07",
"updated_on": "2020-04-15 12:03:07",
"_etag": "8a7d6fe36965164bf1d77e4588c11ee291bfef9e"
}
]
}