我正在使用 CodeIgniter 1.7.1。好的,这是场景。提交表单时,我需要做两件事
1) 保留下拉列表中选择的值。2)使用session->set_flashdata()
,我需要设置自定义数据库消息。
现在我们知道,在设置这个闪存数据之前,我们需要重定向。
这是我写的代码。
if ($this->form_validation->run() == TRUE){
$this->session->set_flashdata(‘msg’, ‘Taha Hasan’);
redirect(current_url());
$this->ShowReceiveInventoryView();
}
我也在下拉视图中使用 set_select 来保留值。
<select name=“myselect”>
<option value=“one” <?php echo set_select(‘myselect’, ‘one’, TRUE); ?> >One</option>
<option value=“two” <?php echo set_select(‘myselect’, ‘two’); ?> >Two</option>
<option value=“three” <?php echo set_select(‘myselect’, ‘three’); ?> >Three</option>
</select>
现在问题来了……闪现消息出现但是因为我正在重定向到当前页面,下拉 set_select 值丢失了!!!默认值出现在选择中:(..如果我删除代码中的重定向行,下拉值是 presisted 但 Flash 数据未设置!!!
希望大家有办法解决这个问题……