我是CodeIgniter的新手。我有一个数据显示的表。每行都有一个编辑按钮。单击编辑按钮时,将弹出模态弹出窗口,然后您就可以对其进行编辑。我的问题是,我不知道如何附加我的控制器的链接。
我的观点:
<a href='<?php echo site_url();?>input_activity/edit/<?php echo $row->activity_detail_id;?>' class="btn btn-outline btn-circle btn-sm purple" data-toggle="modal" >
<i class="fa fa-edit"></i> Edit </a>
我的控制员:
public function edit()
{
$id=$this->uri->segment(3);
$data=array(
'content' =>'activity/v_updateactivity');
$this->load->view('layout/wrapper',$data);
}
表单编辑:
<!-- begin pop update activity -->
<div class="modal fade left" id="">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="pull-left no-margin">Edit Activity</h3>
<button type="button" class="close" data-dismiss="modal" title="Close"><span class="glyphicon glyphicon-remove"></span>
</button>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post" action="<?php echo base_url(); ?>input_activity/update">
<div class="form-group">
<label for="activity" class="col-sm-3 control-label">activity: </label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="activity_name" required><?php echo $detail[0]->name;?></textarea>
<button type="submit" class="btn green">
<i class="fa fa-save"></i> Update</button>
.........
答案 0 :(得分:0)
首先,您需要为模态提供id,与链接相同,如下所示:
<a type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal<?php echo $row->activity_detail_id;?>">Edit</a>
对于模态形式的第一行::
<div class="modal fade left" id="myModal<?php echo $row->activity_detail_id;?>">
然后按以下方式进行表单操作:
<form class="form-horizontal" role="form" method="post" action="<?php echo base_url(); ?>controller-name/function-name/<?php echo $row->activity_detail_id;?>">