⚠ 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

[ANSWERED] How can I pass custom data to callback?



InmatesRunThePlace

InmatesRunThePlace
  • profile picture
  • Member

Posted 24 May 2012 - 19:24 PM

First off - great application. Seriously - it's very well done and overall well documented.

Throughout my application I want to be able to log each CRUD and thought I could do that with callbacks before insert, etc.

My problem is in how to transfer descriptor data to the call back function. This is probably easily accomplished, I just can't figure out how. :)

Thanks for the advice.

Chris

khashabawy

khashabawy
  • profile picture
  • Member

Posted 28 May 2012 - 08:45 AM

same issue here !

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 28 May 2012 - 19:21 PM

Well for now you cannot do that. The only way I can suggest right now is to use the session and when you read the data just unset the session when you retreive the data. I know it is not the best solution for you but I just add this issue at github ( https://github.com/s...-crud/issues/48 ) as it is a feature that can help lot of people.

InmatesRunThePlace

InmatesRunThePlace
  • profile picture
  • Member

Posted 04 June 2012 - 23:18 PM

Thanks. That works well for the time being.

archerwisdom

archerwisdom
  • profile picture
  • Member

Posted 03 April 2014 - 16:05 PM

hi johnny,

 

i tried the session method, but it seems that when i clicked the EDIT button, the session is not captured on the first time,when I refresh the page again, then it will captured the session.


giorgio

giorgio
  • profile picture
  • Member

Posted 29 October 2015 - 16:38 PM

class Admin_model extends CI_Model {
    
    private $variable_to_pass;


public function products() {
        
        $this->variable_to_pass = 123;
        $crud = new grocery_CRUD();

        $crud->callback_after_insert(array($this, 'my_callback'));  
....
      return $output;

}



    function my_callback($post_array,$primary_key) {

        $this->db
            ->where('id', $primary_key)
            ->update('products', array('foo' => $this->variable_to_pass));

        return true;
    }



worked for me.


miningwa

miningwa
  • profile picture
  • Member

Posted 28 March 2016 - 07:27 AM

table A (main)
id
province_id
city_id
prov_longitude
prov_latitude
 
 
 
table B (province)
id_province
province_name
 
 
table C (city)
id_city
city_name
longitude
latitude
 
 
 
$crud->set_relation('province_id','province','province_name');
  
$crud->set_relation('city_id', 'city', 'city_name');


$crud->display_as('provi_id','Province');
$crud->display_as('city_id','City');
 

How to auto insert the longitude and latitude when selecting city??