in a model :
$this->hasMany('id', 'Employees', 'dpt_id', array('alias' => 'DepartmentEmployees', 'foreignKey' => array('message' => 'You cannot delete the department as there are employees assigned.')));
in a controller i try to delete a record that violates the above foreign key
and the action is rejected as expected
$success = $department->delete();
if($success == TRUE)
{
$this->flashSession->success($department->name.' department deleted successfully.');
}
else
{
$rejection_reason = '??'; // I need the message here
$this->flashSession->error(' Could not delete '.$department->name.' department because '.$rejection_reason);
}
the question is : within a controller how can i get the foreign key message ?