⚠ 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

Multiple Callback_before_insert



xmyownprisonx
  • profile picture
  • Member

Posted 25 November 2017 - 06:53 AM

I'm not getting any results while im using multiple callback insert. Is there anyway I can use multiple callback insert? Thank you so much.

 

$crud->callback_before_insert(function($post_array){
            $post_array['userid'] = $this->session->userdata('username');
            return $post_array;
            });

 

$crud->callback_before_insert(function($post_array){
            $post_array['lname'] = $this->session->userdata('last_name');
            return $post_array;
            });

 

$crud->callback_before_insert(function($post_array){
            $post_array['fname'] = $this->session->userdata('first_name');
            return $post_array;
            });

 

 


darkstalker
  • profile picture
  • Member

Posted 25 November 2017 - 10:19 AM

Why multiple callback ? You must use one callback only but you can change multiple values inside that callback. Then you return the post array with the changed values

Amit Shah
  • profile picture
  • Member

Posted 25 November 2017 - 15:41 PM

Well multiple callback is not what the system is currently designed with. For what you can do is you can have 1 single callback.. and in that function you can make a call to the other function before excecuting the actiual callback.

 

Happy GCing :)


xmyownprisonx
  • profile picture
  • Member

Posted 01 December 2017 - 05:43 AM

Thank you Amit and darkstalker. Really appreciate it.


lcoulon
  • profile picture
  • Member

Posted 26 January 2019 - 15:48 PM

Well multiple callback is not what the system is currently designed with. For what you can do is you can have 1 single callback.. and in that function you can make a call to the other function before excecuting the actiual callback.

 

Happy GCing :)

Can you please show us with a code snippet how to do that ?

 

i would to turn several fields in uppercase and i can't get it working.

 

Thanks,