我在一页中有两个模态。一个用于编辑,另一个用于创建。在这两个模式中都包含 select2 选项。以及我从数据库中获得的选项。我想将数据用于两个模态。但是我在模态创建中遇到错误,而模态编辑中没有错误。在模态创建中,它无法显示选择选项中的数据。谁能帮我?
我试试这个
public function detail_produk(){
$data['item']=$this->admin_model->get_all_detail_produk();
$data['ukuran'] = $this->admin_model->get_ukuran();
$data['sidebar'] = $this->load->view('sidebar','',TRUE);
$data['header'] = $this->load->view('header','',TRUE);
$this->load->view('detail_produk', $data);
}
风景
<div class="modal fade" role="dialog" id="detail_user">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Ukuran</label>
<div class="col-sm-10">
<select class="form-control select2" style="width: 100%;" id="ukuran">
<option selected="true" disabled="disabled">Pilih Ukuran</option>
<?php foreach ($ukuran as $ukuran) { ?>
<option value="<?php echo $ukuran['id'];?>"><?php echo $ukuran['size'];?></option>
<?php } ?>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" id="button-simpan" class="btn btn-primary mr-auto" >Simpan</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Kembali</button>
</div>
</div>
</div>
</div>
<div class="modal fade" role="dialog" id="tambah">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
互换的青春
相关分类