⚠ 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

how to send "extra data" to callback_before_insert



insulae

insulae
  • profile picture
  • Member

Posted 15 May 2017 - 16:36 PM

(my english is bad)

 

I need send external data like this:

 

 

$id_external_table = $_GET["id_table"];

...

 

$crud->callback_before_insert(array($this,'function1'), $id_external_table);

...

 

function function1($post_array, $id_external_table) {

        $post_array['id_external_table'] = $id_external_table;

        return $post_array;

 

 

But don't work, How is the correct method?

 


xheradon

xheradon
  • profile picture
  • Member

Posted 16 May 2017 - 07:45 AM

And why not $_POST['id_external_table'] = $_GET['id_table'] ?


insulae

insulae
  • profile picture
  • Member

Posted 16 May 2017 - 12:08 PM

And why not $_POST['id_external_table'] = $_GET['id_table'] ?

I tried, is the same, the problem is: "i cant send extra/custom data to the callback"

 

In this post (year 2012):

/topic/498-answered-how-can-i-pass-custom-data-to-callback/

 

the autor say: "Well for now you cannot do that... but I just add this issue at github as it is a feature that can help lot of people"

 

My new question is: this feature is working now or not? and how?


xheradon

xheradon
  • profile picture
  • Member

Posted 16 May 2017 - 13:46 PM

Maybe accessing get via $this->input->get('id_table'); inside callback? (Didn't try)

 

If not working, use session variables.

 

EDIT: Another possible method, declaring variable like $this->your_variable = $this->input->get('id_table'); and then accessing inside your callback $this->your_variable;


insulae

insulae
  • profile picture
  • Member

Posted 17 May 2017 - 11:55 AM

Maybe accessing get via $this->input->get('id_table'); inside callback? (Didn't try)

 

If not working, use session variables.

 

EDIT: Another possible method, declaring variable like $this->your_variable = $this->input->get('id_table'); and then accessing inside your callback $this->your_variable;

 

ok. this work, creating $this->your_variable =  $my_data then i can get with $this->your_variable inside the callback, thanks!


xheradon

xheradon
  • profile picture
  • Member

Posted 18 May 2017 - 06:34 AM

You're welcome, glad it works.