avoid deletion in before delete callback
- Single Page
Posted 26 September 2012 - 17:12 PM
I'm try to avoid the deletion of the superadmin..
To do this, I set the before delete callback,
$crud->callback_before_delete(array($this,'_avoid_delete_admin_callback'));
function _avoid_delete_admin_callback($post_array, $primary_key = null){
return ($primary_key != 1); // it shoud not allow to delete registrer 1.
}
I thought that returning false abort the deleltion operation.. but it does not.
I've not found anything about this in the documentation..
is posible to do that ?
thanks
Posted 26 September 2012 - 17:18 PM
Posted 26 September 2012 - 17:19 PM
<? var_dump($primary_key != 1);?>
result : bool(true)!
Posted 26 September 2012 - 17:38 PM
php -r '$primary_key=1;var_dump($primary_key != 1);'
bool(false)
anyway, I've realized that the problem is that $primary_key is empty.. ... so returning false directly, it works.. but i dont have the primary_key code..
Maybe a Bug ?
Posted 26 September 2012 - 17:41 PM
It takes one parameter - the primary key value. The return value is not required for this callback.
Your function have two parameters: function _avoid_delete_admin_callback($post_array, $primary_key = null)
Posted 26 September 2012 - 17:50 PM
I dont know why I had two parameters.. surely copy and paste from another callback...
Thank you victor.