dompdf 表单提交没有发送数据 codeigniter
dompdf form submit didn't send data codeigniter
我正在尝试使用 Dompdf 创建 PDF,在我的程序中我有基于表单中输入的动态参数的模型查询,但是当我单击我的按钮以从 select按钮到控制器,数据没有被正确发送,知道为什么吗?下面是我的代码
<form class="form" method="get" action="<?=site_url()?>/laporan/pdfdownload" id="myID" name="myName">
<select id="sel1" class="form-control">
<option disabled selected="selected">Pilih</option>
<?php foreach ($kerja as $rows){?>
<option value="<?php echo $rows->id_project?>"><?php echo $rows->id_project.' - '.$rows->nama_project ?></option>
<?php }?>
</select>
<select id="sel2" class="form-control">
<option disabled selected="selected">Pilih</option>
<?php foreach ($item as $rows){?>
<option value="<?php echo $rows->id_project?>"><?php echo $rows->id_project.' - '.$rows->nama_project ?></option>
<?php }?>
</select>
<button id="filter_button" style="margin-top: 26px;margin-left: 28px;width: auto" name="filter_button" type="submit" class="form btn btn-danger"><i class="fa fa-search"></i> Search</button>
</form>
这是我的控制器
public function pdfdownload(){
//If i click submit then all of the post didnt get sended
$one = $this->input->post('sel1');//no value at all, anyone know why?
$two = $this->input->post('sel2');//no value at all, anyone know why?
$data['real'] = $this->report_m($one,$two)->row();
htmlcontent = $this->load->view('laporan/download/laporan3.php',$data,true);
include(APPPATH."third_party/dompdf/autoload.inc.php");
// require_once APPPATH . 'third_party/dompdf/autoload.inc.php';
$dompdf = new Dompdf\Dompdf();
$dompdf->load_html($htmlcontent);
$dompdf->set_paper("f4");
$dompdf->render();
$dompdf->stream("cobadlu.pdf",array("Attachment" => false));
exit(0);
}
enter code here
在您的 HTML 表单中,您需要使用名称属性,而不仅仅是 ID :
<select id="sel2" name="sel2" class="form-control">
首先你的表格有误:
<form class="form" method="get" action="<?=site_url()?>/laporan/pdfdownload" id="myID" name="myName">
你这里给的方法='get',请改成'post'.
其次,您没有将 'name' 属性包含到输入类型中,因此提交后不会发送任何数据。所以像这样添加名称属性:
<select id="sel1" name="sel1" class="form-control">
<select id="sel2" name="sel2" class="form-control">
我正在尝试使用 Dompdf 创建 PDF,在我的程序中我有基于表单中输入的动态参数的模型查询,但是当我单击我的按钮以从 select按钮到控制器,数据没有被正确发送,知道为什么吗?下面是我的代码
<form class="form" method="get" action="<?=site_url()?>/laporan/pdfdownload" id="myID" name="myName">
<select id="sel1" class="form-control">
<option disabled selected="selected">Pilih</option>
<?php foreach ($kerja as $rows){?>
<option value="<?php echo $rows->id_project?>"><?php echo $rows->id_project.' - '.$rows->nama_project ?></option>
<?php }?>
</select>
<select id="sel2" class="form-control">
<option disabled selected="selected">Pilih</option>
<?php foreach ($item as $rows){?>
<option value="<?php echo $rows->id_project?>"><?php echo $rows->id_project.' - '.$rows->nama_project ?></option>
<?php }?>
</select>
<button id="filter_button" style="margin-top: 26px;margin-left: 28px;width: auto" name="filter_button" type="submit" class="form btn btn-danger"><i class="fa fa-search"></i> Search</button>
</form>
这是我的控制器
public function pdfdownload(){
//If i click submit then all of the post didnt get sended
$one = $this->input->post('sel1');//no value at all, anyone know why?
$two = $this->input->post('sel2');//no value at all, anyone know why?
$data['real'] = $this->report_m($one,$two)->row();
htmlcontent = $this->load->view('laporan/download/laporan3.php',$data,true);
include(APPPATH."third_party/dompdf/autoload.inc.php");
// require_once APPPATH . 'third_party/dompdf/autoload.inc.php';
$dompdf = new Dompdf\Dompdf();
$dompdf->load_html($htmlcontent);
$dompdf->set_paper("f4");
$dompdf->render();
$dompdf->stream("cobadlu.pdf",array("Attachment" => false));
exit(0);
}
enter code here
在您的 HTML 表单中,您需要使用名称属性,而不仅仅是 ID :
<select id="sel2" name="sel2" class="form-control">
首先你的表格有误:
<form class="form" method="get" action="<?=site_url()?>/laporan/pdfdownload" id="myID" name="myName">
你这里给的方法='get',请改成'post'.
其次,您没有将 'name' 属性包含到输入类型中,因此提交后不会发送任何数据。所以像这样添加名称属性:
<select id="sel1" name="sel1" class="form-control">
<select id="sel2" name="sel2" class="form-control">