callback_before_delete

void callback_before_delete(mixed $callback )
Quick Description: This callback runs before the auto delete of the crud.

This callback runs before the auto delete of the crud. It takes one parameter - the primary key value. The return value is not required for this callback.

Example:

 
public function user(){
$crud = new grocery_CRUD();
 
$crud->set_table('cms_user');
$crud->set_subject('User List');
$crud->required_fields('username');
 
$crud->columns('username','email','real_name','active');
$crud->change_field_type('active', 'true_false');
 
$crud->callback_before_delete(array($this,'log_user_before_delete'));
 
$output = $crud->render();
 
$this->_example_output($output);
}
 
public function log_user_before_delete($primary_key)
{
$this->db->where('id',$primary_key);
$user = $this->db->get('cms_user')->row();
 
if(empty($user))
return false;
 
$this->db->insert('user_logs',array(
'user_id' => $primary_key,
'action'=>'delete', 
'email' => $user->email
'updated' => date('Y-m-d H:i:s')));
return true;
}