2016-08-02 7 views
0

私のcodeigniterプロジェクトでform_validationでform_1を作成しようとしています。 form1からの値は、form_validationも持つform_2に転送されます。ここでform_validationでのパラメータの受け渡しCodeigniter

は私のコントローラです:

public function daftar() // form_1 
    { 
    $this->form_validation->set_rules('nama', 'Nama Orang', 'required') 
          ->set_rules('email', 'Email', 'required'); 
     if ($this->form_validation->run() == FALSE) 
     { 
     $this->load->view('daftar'); 
     } else { 
     // if success then show form_2 
     // and save the value from form_1 
     $data = array(
      'nama' =>$this->input->post('nama'), 
      'email' => $this->input->post('email') 
     ); 
     $this->dftr_own_dis($data); 
     } 
    } 
    } 

    public function dftr_own_dis($data_dis) // form_2 contain value from form_1 
    { 
    $this->form_validation->set_rules('nama_pemilik', 'Nama hehe', 'required'); 
    if ($this->form_validation->run() == FALSE) 
     { 
     $data['data_dis'] = $data_dis; 
     $this->load->view('daftar_hehe', $data); 
    } else { 
     echo "succesed all"; 
    } 
    } 

問題は常にFALSEのForm2で、form_1 GET NULLの値は、関数が不足している引数data_disをdaftar_pemilik_disします。

+0

をご確認ください。 2番目の値は、value = $ row-> itemの入力値を持つ必要があります – Brad

答えて

0

pleseはあなたがあなたのフォームを表示したい場合がありますフォーム2バリデーション条件

public function daftar() // form_1 
    { 
    $this->form_validation->set_rules('nama', 'Nama Orang', 'required') 
          ->set_rules('email', 'Email', 'required'); 
     if ($this->form_validation->run() == FALSE) 
     { 
      $this->load->view('daftar'); 

     } else { 

     // if success then show form_2 
     // and save the value from form_1 

     $data = array(
      'nama' =>$this->input->post('nama'), 
      'email' => $this->input->post('email') 
     ); 
     if($this->dftr_own_dis($data)){ 

      // if validation true then you can add you save code here 

      ......... some form or and redirect code or any data save code here ............................. 


     }else { 

      $data['data_dis'] = $data; 

      $this->load->view('daftar_hehe', $data); 
     } 
     } 
    } 
    } 


public function dftr_own_dis($data_dis) // form_2 contain value from form_1 
{ 

    $this->form_validation->set_rules('name', 'Nama hehe', 'required'); 

    if ($this->form_validation->run() == FALSE) 
    { 
     return false; 

    } else { 

     return true; 
    } 
} 
関連する問題