⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

doing callback_before_update for more than 1 function



xcoder
  • profile picture
  • Member

Posted 16 June 2012 - 08:52 AM

How do I do callback_before_update for more 1 function i.e


$crud->callback_before_update(array($this,'id_callback'));
$crud->callback_before_update(array($this,'name_callback'));
$crud->callback_before_update(array($this,'phone_callback'));
$crud->callback_before_insert(array($this,'name_callback'));
$crud->callback_before_insert(array($this,'id_callback'));
$crud->callback_before_insert(array($this,'phone_callback'));
function id_callback($post_array)
{
$post_array["rid"]= $this->session->userdata('id');
return $post_array;
}
function name_callback($post_array)
{
$post_array['rname']= $this->session->userdata('name');
return $post_array;
}
function phone_callback($post_array)
{
$post_array['phone_number']= $this->session->userdata('phone');
return $post_array;
}
function example_output($output = null)
{
$this->load->view('report_missing.php',$output);
}



this only calls back only 'phone_callback'...any help please.Am stuck with my project.

noskov.biz
  • profile picture
  • Member

Posted 16 June 2012 - 11:03 AM

Hi!

Try to write:

$crud->callback_before_update(array($this,'_my_callback'));


and then:

public function _my_callback($post_array, $primary_key)
{
$post_array["rid"]= $this->session->userdata('id');
$post_array["rname"]= $this->session->userdata('name');
$post_array["rphone"]= $this->session->userdata('phone');
// other session data
return $post_array;
}

xcoder
  • profile picture
  • Member

Posted 17 June 2012 - 07:24 AM

That worked.Thanks