[eluser]TWP Marketing[/eluser]
[quote author="Rosiadi" date="1345750016"]hello guys. I'm still newbie in CI. I try to load session which set in same file controller. after set the session, I load the view. and in that view I call again a function in controller. but there is no data set. can someone explain where my false??
here ini my code which set the session
Code:
function ViewUpdate($data)
{
$this->session->set_userdata('nota2', $this->nota);
$this->data['h2_title'] = 'NotaDinas > Update Data';
$this->data['tampilan'] = 'NotaDinasUpdate';
$this->data['link'] = array('link_back' => anchor('NotaDinasUpdate/','kembali', array('class' => 'back'))
);
$this->data = array_merge($this->data, $data);
$tmpl = array( 'table_open' => '<table border="0" cellpadding="2" cellspacing="2">',
'row_alt_start' => '<tr class="zebra">',
'row_alt_end' => '</tr>'
);
$this->table->set_caption("Address Book");
/*--------------------------------Table List Dari-----------------------------------------------*/
$milis = $this->NotaModel->getAllStaff();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
//print_r($mil);
$this->table->add_row($mil->KODE_OBJEK,$mil->NAMA_OBJEK,anchor('ControllerBukaNota/addedAtasan/'.$mil->KODE_OBJEK,'Pilih'));
}
$this->data['tableDari'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table List Dari----------------------------------------*/
/*--------------------------------Table List Pemeriksa-----------------------------------------------*/
$milis = $this->NotaModel->getAllStaff();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
$this->table->add_row($mil->KODE_OBJEK,$mil->NAMA_OBJEK,anchor('ControllerBukaNota/addedPemeriksa/'.$mil->KODE_OBJEK,'Pilih'));
}
$this->data['tablePemeriksa'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table List Pemeriksa----------------------------------------*/
/*--------------------------------Table List Tembusan-----------------------------------------------*/
$milis = $this->NotaModel->getAllStaff();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
$this->table->add_row($mil->KODE_OBJEK,$mil->NAMA_OBJEK,anchor('ControllerBukaNota/addedTembusan/'.$mil->KODE_OBJEK,'Pilih'));
}
$this->data['tableTembusan'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table List tembusan----------------------------------------*/
/*--------------------------------Table List Kode Masalah--------------------------------------------*/
$milis = $this->NotaModel->getKodeMasalah();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
$this->table->add_row($mil->KODE_MASALAH,$mil->NAMA_MASALAH,anchor('ControllerBukaNota/addedKM/'.$mil->KODE_MASALAH.'/'.$data['awal'],'Pilih'));
}
$this->data['tabelKM'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table Kode Masalah-------------------------------------*/
/*--------------------------------Table List BUMN--------------------------------------------*/
$milis = $this->NotaModel->getAllBUMN();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
$this->table->add_row($mil->KODE_OBJEK,$mil->NAMA_OBJEK,anchor('ControllerBukaNota/addedBumn/'.$mil->KODE_OBJEK,'Pilih'));
}
$this->data['tabelBUMN'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table BUMN-------------------------------------*/
/*--------------------------------Table List Pegawai--------------------------------------------*/
$milis = $this->NotaModel->getAllStaff();
$this->table->set_template($tmpl);
$this->table->set_empty(" ");
foreach ($milis as $mil)
{
$this->table->add_row($mil->KODE_OBJEK,$mil->NAMA_OBJEK,anchor('ControllerBukaNota/addToFieldKepada/'.$mil->KODE_OBJEK.'/'.$data['awal'],'Pilih'));
}
$this->data['tabelPegawai'] = $this->table->generate();
$this->table->clear();
/*--------------------------------End Table List Pegawai-------------------------------------*/
$this->load->helper('form');
$this->session->set_userdata('data',$this->data);
$this->load->view('test', $this->data);
}
and here my code which want to load $this->data
Code:
public function AddedKM($kmi, $dat)
{
$this->data['tabelKM'] = $kmi;
$this->session->set_userdata("data",$this->data);
$this->ViewUpdate($this->data);
}
my goal in here just to replace $this->data['tabelKM'] in the session but there was no data in $this->data. it's empty. please help me...[/quote]
Rosaidi
In your method (AddedKM($kmi, $dat) do you mean to use" $data" and not "$dat" ...
Also, you are using a var ($data) in your controller, referencing it as $this->data. however you also have a second var, also called ($data) in the method (ViewUpdate($data) it is not a good idea to use the same name for both.
Also, did you load the session library in your autoload file?