Welcome Guest, Not a member yet? Register   Sign In
How do I repopulate fields BEFORE validation is passed?
#11

[eluser]RalphLeMouf[/eluser]
// CONTROLLER

Code:
if($this->form_validation->run() == FALSE )
   {
    
    $data['main_content'] = 'account/edit';
    $this->load->view('includes/templates/main_page_template', $data);
    
   }
   elseif($this->form_validation->run() == TRUE)
   {
    $birthdate = $this->input->post('year') . "-" . $this->input->post('month') . "-" . $this->input->post('day');
    $save_data = array(
        'relation' => $this->input->post('relation'),
     'location' => $this->input->post('location'),
     'birthday' => date('Y-m-d',strtotime($birthdate)),
     'gender' => $this->input->post('gender'),
     'mylife' => $this->input->post('mylife'),
     'occupation' => $this->input->post('occupation'),
     'hobbies' => $this->input->post('hobbies'),
     'books' => $this->input->post('books'),
     'music' => $this->input->post('music'),
     'movies' => $this->input->post('movies'),
     'quote' => $this->input->post('quote'),
     'mycysticlife' => $this->input->post('mycysticlife'),
     'medicines' => $this->input->post('medicines'),
     'treatments' => $this->input->post('treatments'),
     'PFTs:FVC' => $this->input->post('PFTs:FVC'),
     'FEV1' => $this->input->post('FEV1'),
     'mutation' => $this->input->post('mutation'),
     'twitter' => $this->input->post('twitter'),
     'myspace' => $this->input->post('myspace'),
     'facebook' => $this->input->post('facebook'),
     'blogspot' => $this->input->post('blogspot'),
     'youtube' => $this->input->post('youtube'),
     'url' => $this->input->post('url'),
     'city' => $this->input->post('city'),
            );
  
    
    $query = $this->account_model->update_edit($user['id'],$save_data);
    $data['main_content'] = 'account/welcome';
    $this->load->view('includes/templates/main_page_template', $data);
   }
  
  }
}



#12

[eluser]CroNiX[/eluser]
Look at the form_dropdown() function of the form helper. Use that in conjunction with set_value() to show the posted value on validation failure. You are creating all your selects manually which is a lot more difficult than the built in functions codeigniter provides.




Theme © iAndrew 2016 - Forum software by © MyBB