Code: Select all
/**
* This method is invoked before deleting a record (after validation, if any)
* @param string $pk
* @return boolean
*/
protected function _beforeDelete($pk = '')
{
if($this->count() > 1){
return true;
}else{
$this->_error = true;
$this->_errorMessage = A::t('core', 'You cannot delete the last remaining record in table {table}!', array('{table}'=>'<b>'.ucfirst($this->_table).'</b>'));
return false;
}
}
Of course, you may use this way to prevent deleting last X records (according to your needs).