codeigniter form_radio如何在控制器中获取值

时间:2017-10-26 16:03:16

标签: php codeigniter-3

我有多个单选按钮和一个下拉列表。我想根据所选值填充列表。问题是我无法在控制器中获得所选值。 视图:

<?php echo form_open(base_url() . 'controller/method');
 $type1 = array(
'name' => 'category',
'id'=> '1',
'value' => 't1',
'checked' => TRUE,
);
echo form_radio($type1);
echo form_label('Type 1');
$type2 = array(
'name' => 'category',
'id'=> '2',
'value' => 't2',
);
echo form_radio($type2);
echo form_label('Type 2');
$type3 = array(
'name' => 'category',
'id'=> '3',
'value' => 't3',
);
echo form_radio($type3);
echo form_label('Type 3');
echo form_close();
 ?>

控制器:

$category= $this->input->post('category');

当我尝试:

if(isset($category)){
   echo $category;
}
else{
   echo "variable is not there";
}

我总是得到“变量不存在”。

0 个答案:

没有答案