⚠ 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 use callback_column



voriand
  • profile picture
  • Member

Posted 22 August 2018 - 19:14 PM

Hi!

 

I want to use the callback_column function to make some SQL update in the background as the rows are displayed.

 

This is my GC code in the view:

<?php $crud = new grocery_CRUD();
$crud->where('(status IS NULL) OR (assigned_to = '.$id.')');
$crud->order_by('id','ASC');
$crud->limit(3,0);
$crud->set_table('mobil_lead');
$crud->columns('mobile_number', 'package_name', 'package_end_date');
$crud->field_type('mobile_number', 'readonly');
$crud->field_type('package_end_date', 'readonly');
$crud->change_field_type('contacted_by', 'hidden', $id);
$crud->change_field_type('contacted_at', 'hidden', date('Y-m-d'));
$crud->change_field_type('created_at', 'hidden');
$crud->change_field_type('modified_at', 'hidden', date('Y-m-d'));

if(!$this->CI->isAdmin($id)){
$crud->unset_add();
}

$crud->callback_column('mobile_number', array($this,'_callback_assign_to_user_home'));

function _callback_assign_to_user_home($value, $row){

return $row->mobil_number;
}

$output = $crud->render();

$this->load->view('mobil.php', $output); ?>

The callback function is just a test I removed everything from it, but it still gives me:

 

 
A PHP Error was encounteredSeverity: Warning
Message: call_user_func() expects parameter 1 to be a valid callback, class 'CI_Loader' does not have a method '_callback_assign_to_user_home'
Filename: libraries/Grocery_CRUD.php
Line Number: 1867

So my question is: where exactly should I write the callback function exactly and how to call it without errors?

 

Thank you :)