2016-08-02 7 views
0

Ich versuche, Form_1 mit form_validation in meinem codeigniter Projekt zu erstellen. Die Werte von form1 werden in form_2 übertragen, die auch form_validation haben.Übergeben von Parametern auf form_validation Codeigniter

Hier ist mein Controller:

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"; 
    } 
    } 

Das Problem ist form2 immer FALSCH und die Werte von form_1 get NULL machen die Funktion daftar_pemilik_dis Argumente data_dis fehlt.

+0

Vielleicht möchten Sie Ihre Formulare zeigen. Die zweite für muss möglicherweise Formulareingabewerte von Wert = $ row-> item haben – Brad

Antwort

0

Plese Scheckformular 2 Validierungsbedingung

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; 
    } 
} 
Verwandte Themen