我在单击链接时显示引导模式的视图。我已在此模式中提交表单。 bootstrap模式中的字段通过javascript填充。我的问题是,当我提交表单时,我没有在控制器中获取POST中的值。我无法找到我出错的地方。
这是我的代码:
查看:
<script>
function showmodal(internaltt,indusid,eqptname,eqptmake,priority)
{
var complaintid=internaltt;
document.getElementById("nhiddenevent").value = complaintid;
document.getElementById("ninternaltt").value = complaintid;
document.getElementById("nindusid").value = indusid;
document.getElementById("faulty").value = eqptname;
document.getElementById("faultymake").value = eqptmake;
document.getElementById("priority").value = priority;
$('#responsiveshow').modal('show');
}
</script>
<table class="table table-striped table-hover table-bordered" id="sample_editable_1">
<thead>
<tr>
<th>
TT Number
</th>
<th>
Indus ID
</th>
<th>
Date
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<?php
if(isset($list) && !empty($list))
{
foreach($list as $complaints)
{
?>
<tr>
<td>
<?php echo $complaints->complaint_id;?>
</td>
<td>
<?php echo $complaints->indus_id;?>
</td>
<td>
<?php echo $complaints->created_date;?>
</td>
<td>
<a href="" onClick="showmodal(<?php echo $complaints->complaint_id;?>,'<?php echo $complaints->indus_id;?>','<?php echo $complaints->faulty_equipment;?>','<?php echo $complaints->faulty_eqpt_make;?>','<?php echo $complaints->priority;?>')" data-toggle="modal">View </a>
</td>
</tr>
<!------------ BEGIN MODAL ------------------------- -->
<!-- /.modal -->
<div id="responsiveshow" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">Complaints</h4>
</div>
<div>
<?php
echo form_open("index.php/complaints/registerindus"); ?>
<div class="modal-body">
<div class="scroller" style="height:300px" data-always-visible="1" data-rail-visible1="1">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label">TT Number</label>
<input type="text" placeholder="TT Number" class="form-control" name="ninternaltt" id="ninternaltt"/>
</div>
<div class="form-group">
<label class="control-label">Indus TT Number</label>
<input type="text" placeholder="Indus TT Number" class="form-control" name="nindustt" id="nindustt"/>
</div>
<div class="form-group">
<label class="control-label">Indus ID</label>
<input type="text" placeholder="Indus ID" class="form-control" name="nindusid" id="nindusid"/>
</div>
<div class="form-group">
<label class="control-label">Faulty Equipment</label>
<input type="text" placeholder="TT Number" class="form-control" name="faulty" id="faulty"/>
</div>
<div class="form-group">
<label class="control-label">Faulty Equipment Make</label>
<input type="text" placeholder="TT Number" class="form-control" name="faultymake" id="faultymake"/>
</div>
<div class="form-group">
<label class="control-label">Priority</label>
<input type="text" placeholder="TT Number" class="form-control" name="priority" id="priority"/>
<input type="hidden" name="nhiddenevent" id="nhiddenevent">
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn default">Close</button>
<input type="submit" class="btn green" value="Update Indus ID">
</div>
</div>
<?php echo form_close();?>
</div>
</div>
</div>
<!-- /.modal -->
<!-- --------------- END MODAL ------------ -->
<?php
}
}
?>
</tbody>
</table>
控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Complaints extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('complaints_model');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
}
public function registerindus()
{
$internaltt=$this->input->post('ninternaltt'); //here m not getting the values from view
$industt=$this->input->post('nindustt'); //here m not getting the values from view
$eturn=$this->complaints_model->updateIndusTT($internaltt,$industt);
if($return)
{
$this->index();
}
else
{
$this->listunregistered();
}
}
}
任何人都可以帮我解决这个问题..提前致谢
答案 0 :(得分:0)
变化
<?php echo form_open("index.php/complaints/registerindus"); ?>
到
<?php echo form_open("complaints/registerindus"); ?>
以下是一个简单示例:echo form_open('email/send');
上面的示例将创建一个表单,指向您的基本网址以及&#34; email / send&#34; URI段,如下所示:
<form method="post" accept-charset="utf-8" action="http:/example.com/index.php/email/send" />
还通过在控制器函数中回显post值来调试代码
然后是一个错字
$eturn=$this->complaints_model->updateIndusTT($internaltt,$industt);
应该是
$return=$this->complaints_model->updateIndusTT($internaltt,$industt);