2016-10-04 76 views
0

我是CodeIgniter的新手。我有一張表格顯示數據。在每一行中都有一個編輯按鈕。點擊編輯按鈕後,會彈出一個模式彈出窗口,然後您可以對其進行編輯。我的問題是,我不知道如何附加我的控制器的鏈接。modal bootstrap表單在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() 
 
{ 
 
\t $id=$this->uri->segment(3); 
 
\t $data=array(
 
\t 'content' =>'activity/v_updateactivity'); 
 
\t $this->load->view('layout/wrapper',$data); 
 
} 
 
\t

形式編輯:

<!-- 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> 
 
\t \t \t \t 
 
<button type="submit" class="btn green"> 
 
<i class="fa fa-save"></i> Update</button> 
 
.........

回答

0

首先,您需要提供身份證的模式爲相同的鏈接如下:

<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;?>">

+0

你可以給我示例控制器 –

+0

公共功能編輯() { \t的$ id = $此 - > URI->段(3); \t $ data = array( \t「activity_name」=> $ this-> input-> post('name_activity'),); \t $ this-> db-> where('id',$ id); $這 - > DB->更新( 'TABLE_NAME',$數據);重定向(); } – Rupinder