In case you've missed it, you are looking at an older version of the website. Checkout our latest version, we promise you will love it 😍

callback_insert

void callback_insert(mixed $callback )
Quick Description: This callback escapes the auto insert of the CRUD, and runs only the inserted callback.

This callback escapes the auto insert of the CRUD, and runs only the inserted callback.

Example:

public function users(){
    $crud = new grocery_CRUD();
    $crud->set_table('db_user');
    $crud->set_subject('User');
    $crud->required_fields('user_name');
 
    $crud->columns('user_name','email','real_name','active', 'groups');
    $crud->fields('user_name','email','password','real_name','active', 'groups');
    $crud->change_field_type('password', 'password');
 
    $crud->callback_insert(array($this,'encrypt_password_and_insert_callback'));
 
    $output = $crud->render();
    $this->_example_output($output);
}
 
function encrypt_password_and_insert_callback($post_array) {
  $this->load->library('encrypt');
  $key = 'super-secret-key';
  $post_array['password'] = $this->encrypt->encode($post_array['password'], $key);
 
  return $this->db->insert('db_user',$post_array);
}