Jump to content


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


  • Please log in to reply
6 replies to this topic

#1 InmatesRunThePlace

InmatesRunThePlace

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 24 May 2012 - 07: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

#2 khashabawy

khashabawy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 28 May 2012 - 08:45 AM

same issue here !

#3 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,099 posts
  • LocationLondon

Posted 28 May 2012 - 07: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.
Posted Image

#4 InmatesRunThePlace

InmatesRunThePlace

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 04 June 2012 - 11:18 PM

Thanks. That works well for the time being.

#5 archerwisdom

archerwisdom

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 03 April 2014 - 04: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.



#6 giorgio

giorgio

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 29 October 2015 - 04: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.



#7 miningwa

miningwa

    Newbie

  • Members
  • Pip
  • 3 posts

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??






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users