我的观点中有下拉列表
<div class="col-md-4">
<select id="news_category" name="ed_news_category" class="form-control">
<?php
foreach ($news_category_data as $ncat ) {?>
<option
<?php
if($cat_for_news->nc_id == $ncat->nc_id) { echo "selected" ;}
?>
value="<?php $ncat->nc_id ?>"><?php echo $ncat->nc_id ," - ", $ncat->news_category_name ?>
</option>
<?php } ?>
</select>
并在我的控制器中获取下拉值并返回空
'news_category_id' => string '' (length=0)
我的控制器是:
$ed_ne_data = array(
'titel' => $this->input->post('ed_news_title') ,
'content' => $this->input->post('ed_news_content') ,
'news_category_id' => $this->input->post('ed_news_category') ,
'img_url' => $this->newsModel->getNewsToEdit($ed_ne_id)->img_url,
'created_at' => date("Y-m-d")
);
我是怎么解决的
感谢
答案 0 :(得分:0)
因为您忘记在选项值中回显值
更改
value="<?php $ncat->nc_id ?>"
要
value="<?php echo $ncat->nc_id ?>"
^^^^^