Screen following BeforeDelete

i sure appreciate all the great info on this forum...much appreciated.
i could use some help with a beforedelete() function. the following function is working as needed. it checks for existing rows in a child table, and if any are found, an error is returned to prevent deletion of the parent. After the error is returned, though, the user is dropped into the 'show all' screen instead of remaining on the 'edit' screen. so currently the flow is:
1. list screen
2. edit screen
3. click the delete button
4. check for child records. child records found
5. error message is displayed "cannot delete record because child records exist"
6. show all screen is displayed.
so...how do make sure that after the delete button is clicked and the error message is displayed, the user remains on the edit screen ?
Thanks in advance for the help.
if ( isset($record) ){
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$keyid = $record->val('ps_project_stage_id');
$key_field = "pd_project_stage_id";
$table = "project_deliverables";
$msg = "This STAGE cannot be deleted. It is being used in 1 or more DELIVERABLES.";
$sql = "select count(*) as row_count from ".$table;
$sql = $sql." where ".$key_field;
$sql= $sql." = ".$keyid;
$res = mysql_query($sql);
$num_rows = mysql_result($res,0);
if ($num_rows > 0 ){
return Dataface_Error::permissionDenied($msg);
}
}
i could use some help with a beforedelete() function. the following function is working as needed. it checks for existing rows in a child table, and if any are found, an error is returned to prevent deletion of the parent. After the error is returned, though, the user is dropped into the 'show all' screen instead of remaining on the 'edit' screen. so currently the flow is:
1. list screen
2. edit screen
3. click the delete button
4. check for child records. child records found
5. error message is displayed "cannot delete record because child records exist"
6. show all screen is displayed.
so...how do make sure that after the delete button is clicked and the error message is displayed, the user remains on the edit screen ?
Thanks in advance for the help.
if ( isset($record) ){
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$keyid = $record->val('ps_project_stage_id');
$key_field = "pd_project_stage_id";
$table = "project_deliverables";
$msg = "This STAGE cannot be deleted. It is being used in 1 or more DELIVERABLES.";
$sql = "select count(*) as row_count from ".$table;
$sql = $sql." where ".$key_field;
$sql= $sql." = ".$keyid;
$res = mysql_query($sql);
$num_rows = mysql_result($res,0);
if ($num_rows > 0 ){
return Dataface_Error::permissionDenied($msg);
}
}