|
发表于 2011-11-7 11:41:24
|
显示全部楼层
我也碰到同样的问题...回调函数执行的时候正确之后不能跳到正确的页面
//添加
function add_save(){
// $this->form_validation->set_rules('title', '标题', 'required');
// $this->form_validation->set_message('required', '%s名称不能为空');
// if($this->form_validation->run()==TRUE){
if($this->form_validation->run('signup')==TRUE){
echo 1;
$date = array(
'title' =>$this->input->post('title')
,'neirong' =>$this->input->post('neirong')
,'datetime' => time()
);
$this->mlyb->insert('lyb',$date);
}
// redirect(site_url('lyb/index'));
// $this->load->view('lyb_index');
$this->index();
}
//自定义错误提示
function null_check($str){
echo $str;
if(empty($str)){
echo $str;
$this->form_validation->set_message('null_check', '%s不能为空');
return FALSE;
}
else{
echo 1;
return TRUE;
}
}
还有个问题就是回调之后不能重新填充表单
<table>
<tr>
<td colspan="2">添加留言板</td>
</tr>
<tr>
<td >标题:</td>
<td><input type="text" name='title' value="<?php echo set_value('title'); ?>" id='title' /><?php echo form_error('title'); ?></td>
</tr>
<tr>
<td>内容:</td>
<td><textarea rows="5" cols="20" name="neirong" id="neirong"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="保存" /></td>
</tr>
</table> |
|