用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1237|回复: 1
收起左侧

[版本 3.x] 方法内ID值的传递问题。

[复制链接]
发表于 2016-5-31 02:14:45 | 显示全部楼层 |阅读模式
//显示填写表单
    public function add(){
     $id=$this->uri->segment(4);
     $data['id']=$id;
     $data['title']=$this->db->select('title')->from('qtype')->where('id',$id)->get()->result_array();
    /* echo $data[0]['title']['title'];      
     p($data);die;*/
     $this->load->view('index/add.html',$data);

    }
现在根据表单验证情况,没通过返回到add方法中。
public function addpost(){

            $id=$this->input->post('id');
            $title=$this->input->post('title');
            $content=$this->input->post('content');
            $address=$this->input->post('address');
      //执行表单验证
      /*
       * 载入验证类
       */
       $this->load->library('form_validation');
       $this->load->helper('form');
       $this->form_validation->set_rules('title','标题','required');
       $this->form_validation->set_rules('content','内容','required');
       $this->form_validation->set_rules('content','发生地点','required');
       if($this->form_validation->run()==FALSE){
      
              $this->add();

       }

ID值怎么传过去呢?

发表于 2016-5-31 09:01:54 | 显示全部楼层
public function add($id){}  这样写      $this->add($id);   就行了

本版积分规则