By overriding the delete
function of GroceryCRUD
as below, we can easily soft-delete a record.
public function user() {
$crud = new grocery_CRUD();
$crud->set_table('cms_user');
$crud->set_subject('User List');
$crud->required_fields('user_name');
$crud->columns('user_name','email','real_name','active');
$crud->change_field_type('active', 'true_false');
$crud->callback_delete(array($this,'delete_user'));
$output = $crud->render();
$this->_example_output($output);
}
public function delete_user($primary_key) {
return $this->db->update(
'cms_user',
array('deleted' => '1'),
array('id' => $primary_key)
);
}
My question is, How do I hide the soft-deleted records in the Main View ??
Thank you.
The answer was easy... after some googling it is obvious I can use the where
clause
$crud->where('deleted', '0');
Thank you all... works like a charm