Welcome Guest, Not a member yet? Register   Sign In
issue with re-populating the field values after form validation
#3

[eluser]Mithun[/eluser]
Validation library is already loaded in autoload.php
Code:
$autoload['libraries'] = array('database', 'session','template','DX_Auth', 'Form_validation', 'validation');
$autoload['helper'] = array('html', 'url','form');

Controller is
Code:
function add()
{
     $data = array();

     $this->load->library('validation');
     $rules['name']    = "trim|required|min_length[1]|max_length[12]|xss_clean";
     $rules['assigned_id']    = "trim|required|";
     $this->validation->set_rules($rules);

     if ($this->validation->run()){
         $this->db->insert('locations',$data);
         redirect('/locations/index/');
     } else {

         $this->template->write_view('content','locations/add',$data);

     }
     $this->template->render();
}

view is
Code:
<?php
    $name = array(
        'id'=>'location_add_name',
        'name' => 'name',
        'value' => set_value('name')
    );
    
    $address = array(
        'id' => 'location_add_address',
        'name' => 'address',
        'value' => set_value('address')
    );
    
    $assigned_id = array(
        'id' => 'location_add_address_assigned_id',
        'name' => 'assigned_id',
        'value' => set_value('assigned_id')
    );
    print_r($name);
?>

and the output of the print_r($name) is
Code:
Array
(
    [id] => location_add_name
    [name] => name
    [value] =>

Value of name is not repopulated :-(p


Messages In This Thread
issue with re-populating the field values after form validation - by El Forum - 01-21-2010, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB