我是codeigniter的新手,我不知道如何使用它...请帮忙。
这是我的视图文件(manufacturers.php)
<thead>
<tr>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<?php echo $this->session->flashdata('message'); ?>
<?php $offset = $this->uri->segment(3, 0) + 1; ?>
<?php foreach ($query->result() as $row); ?>
<tr>
<td><?php echo $row->manufacturer_name; ?></td>
<th>
<a class="btn btn-warning btn-xs" data-toggle="modal" data-target=".bs-editmanuf-modal-lg"><i class="fa fa-edit"></i></a>
<?php $this->load->view('modals/editmanufacturer');?>
</tr>
</tbody>
这是我的编辑模式(editmanufacturer.php)
<div class="form-group">
<label for="manufacturer_id" class="col-sm-2 control-label">ID :</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="manufacturer_id" name="manufacturer_id" placeholder="manufacturer_id">
</div>
</div>
<div class="form-group">
<label for="manufacturer_name" class="col-sm-2 control-label">Name :</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="manufacturer_name" placeholder="manufacturer_name" name="manufacturer_name">
</div>
</div>
<br>
<input type="submit" value="Update" class="btn btn-primary" />
</div>
我不知道该把什么放在我的控制器和型号上......请帮忙!!!
答案 0 :(得分:0)
请在edit.php文件中包含以下标记
/&#34;您的控制器名称&#34; /&#34;您的控制器功能名称&#34; ID =&#34; student_form&#34;方法=&#34;后&#34; &GT;
答案 1 :(得分:0)
尝试这样..希望它会帮助..
首先将你的模态主div放入你的视图文件中以加载这样的模态。
<a class="btn btn-warning btn-xs" onclick="edit_manufacture_popup(<?php echo $row->manufacturer_id;?>);"><i class="fa fa-edit"></i></a>
此链接是您的编辑点击链接
function edit_manufacture_popup(manufacturer_id)
{
//alert(manufacturer_id)
$.ajax
({
url : "<?php echo base_url('manufacture/ajax_edit_manufacture_popup');?>",
type : 'POST',
data :{manufacturer_id : manufacturer_id},
success: function(data)
{
$('#add_manufacture_popup').html(data);
$('#add_manufacture_popup').modal({
backdrop: 'static',
keyboard: false
});
}
});
}
使用函数来打开你的编辑模式......然后传递你的制造商ID
function ajax_edit_manufacture_popup()
{
//print_r($_POST); die;
$data['manufacturer_id'] = $_POST['manufacturer_id'];
// get your data by manufacture id and passed to the modal
echo $this->load->view('modals/editmanufacturer',$data,true);
}
在你的制造商控制器中制作ajax_edit_manufacture_popup函数你可以像这样加载你的模态数据......
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form id="frm_edit_manufacture" method="post">
<div class="modal-header">
</div>
<div class="modal-body">
<div class="form-group">
<label for="manufacturer_id" class="col-sm-2 control-label">ID :</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="manufacturer_id" name="manufacturer_id" placeholder="manufacturer_id" value="<?php echo $manufacture_data['manufacture_id'];?>">
</div>
</div>
<div class="form-group">
<label for="manufacturer_name" class="col-sm-2 control-label">Name :</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="manufacturer_name" placeholder="manufacturer_name" name="manufacturer_name" value="<?php echo $manufacture_data['manufacturer_name'];?>">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" value="Update" class="btn btn-primary" />
</div>
</div>
</form>
</div>
</div>
加载此模态时将绑定div的add_manufacture_popup id
最后你的模态看起来像这样..
Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vib.vibrate(500);
Toast.makeText(this, "vib started", Toast.LENGTH_LONG).show();
您可以使用您的制造ID更新您的表格..我相信它会帮助您..