Jump to content


[solved] How to show message if delete not success?

delete message

  • Please log in to reply
1 reply to this topic

#1 jinbatsu

jinbatsu

    Member

  • Members
  • PipPip
  • 23 posts

Posted 18 December 2013 - 06:00 AM

Hello,

 

If data row is not deleted, it doesn't show any text message.

How can I display it?

 

EDIT:

Should I use callback_after_delete?

And check if the data is still exist?

Is there a way to show the error message?

 

 

Thank You



#2 jinbatsu

jinbatsu

    Member

  • Members
  • PipPip
  • 23 posts

Posted 14 January 2014 - 05:31 PM

I can do this with:

$crud->set_lang_string('delete_error_message', 'My Own Error Message Here!');
$crud->callback_before_delete(array($this,'cek_before_delete'));

	function cek_before_delete($primary_key) {
		$this->db->db_debug = false; // IMPORTANT! (to make temporary disable debug)
		$this->db->trans_begin();
		$this->db->where('id', $primary_key);
		$this->db->delete('your_table');
		$num_rows = $this->db->affected_rows();
		$this->db->trans_rollback();
		if ($num_rows > 0) {
			return TRUE;
		} else {
			return FALSE;
		}
	}






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users