表单帮助程序不会发送任何隐藏变量。 代码在视图中:
foreach($query->result() as $row)
{
$hidden = array('drop-user-process' => TRUE, 'dropped-user-id' => $row->u_id, 'schoolid' => $schoolInfo[0]->ps_id);
echo form_open('core/school', '', $hidden);
echo '<tr>';
echo '<th scope="row">'.$i.'</th>';
echo '<td>'.$row->u_name.'</td>';
echo '<td>'.$row->u_surname.'</td>';
echo '<td>'.$row->u_email.'</td>';
if($this->session->userdata('u_id') == $schoolInfo[0]->ps_admin_id) {
echo '<td><button type="submit" class="btn btn-sm btn-danger">Wyrzuć</button></td>';
} else {
echo '<td><span class="badge badge-secondary">Brak uprawnień</span></td>';
}
echo '</tr>';
$i++;
echo form_close();
}
控制器中的代码(日志消息返回空变量&#34; drop-user-process&#34;)
if(!empty($this->input->post('drop-user-process')) == TRUE)
{
log_message('debug', 'CORE: school, drop user not empty');
if($this->core_model->kickUserFromSchool($this->post->input('dropped-user-id'), $this->input->post('schoolid')) == TRUE)
{
log_message('debug', 'CORE CONTROLLER: school, return TRUE; school id: '.$this->input->post('schoolid').', kicked user id: '.$this->input->post('dropped-user-id'));
redirect(base_url('school/'.$this->input->post('schoolid')));
}
else
{
log_message('debug', 'CORE CONTROLLER: school, return TRUE; school id: '.$this->input->post('schoolid').', kicked user id: '.$this->input->post('dropped-user-id'));
redirect(base_url('school/'.$this->input->post('schoolid')));
}
}
答案 0 :(得分:0)
试试这个
<?php echo form_open();?>
<?php echo form_hidden('_hidden_field','TEST');?>
<?php echo form_input('username', 'John');?>
<?php echo form_close();?>
答案 1 :(得分:0)
在使用表单之前,您必须加载form_helper 试试这个:
function some_function() {
$this->load->helper('form');
$hidden = array('drop-user-process' => TRUE, 'dropped-user-id' => $row->u_id, 'schoolid' => $schoolInfo[0]->ps_id);
echo form_open('core/school', '', $hidden);
// do more
}