Welcome Guest, Not a member yet? Register   Sign In
Pre-populated form with validation class
#1

[eluser]Unknown[/eluser]
Hi,

I have an "edit" page for a form and am using the validation class, but can't figure out how to display the initial value retrieved from the database. If I have to assign the value of the validation to the input, what's a good way to pre-populate the field with the initial value?

view:
Code:
echo form_input('name', $this->validation->name);

controller:
Code:
public function edit() {

    $this->load->model('Company_model');
    $this->load->library('validation');

    $vrules['id'] = 'required';
    $vrules['name'] = 'trim|required';
    $this->validation->set_rules($vrules);

    $vfields['id'] = 'ID';
    $vfields['name'] = 'Name';
    $this->validation->set_fields($vfields);

    if($this->validation->run()) {

        // update db and do stuff
    
    } else {

        $id = $this->uri->segment(3);
        $data['query'] = $this->Company_model->get_single($id);

        // display form
        $this->load->view('header', $data);
        $this->load->view('company/edit');
        $this->load->view('footer');

    }
}


Messages In This Thread
Pre-populated form with validation class - by El Forum - 03-30-2008, 06:05 PM
Pre-populated form with validation class - by El Forum - 03-30-2008, 06:41 PM
Pre-populated form with validation class - by El Forum - 03-31-2008, 03:45 AM
Pre-populated form with validation class - by El Forum - 03-31-2008, 04:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB