⚠ 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

more than one callback ?



richb201
  • profile picture
  • Member

Posted 23 July 2020 - 13:51 PM

Can I use $crud->callback_before_insert() and $crud->callback_after_upload() in the same CRUD function in the controller? How about two calls such as 

 $crud->callback_before_insert(a) 

 $crud->callback_before_insert(g)

??

 

 

 

 


richb201
  • profile picture
  • Member

Posted 23 July 2020 - 19:59 PM

The reason that I am asking is that I am having trouble with call backs and I am not sure what the problem is. I have  callback 

$crud->callback_after_insert(array($this, 'add_email'));

 

here is add email:

function add_email($post_array)
{
$post_array['email'] = $this->session->userdata('userid');
$post_array['campaign'] = $this->session->userdata('campaign');

return $post_array;

}

 

The problem is that unless the field email and the field campaign display in the add form, they don't appear in the post array. Thus if I have made them invisible in the add form like this:

$crud->change_field_type('email', 'invisible');
$crud->change_field_type('campaign', 'invisible');

 

They don't appear in the $post_array  and I can't change them.