How to Halt Hook Execution & Display Alert Error

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
thecomputerchap
Veteran Member
Posts: 47
Joined: 2016-08-28 10:37

How to Halt Hook Execution & Display Alert Error

Post by thecomputerchap » 2016-10-20 08:40

Hi all,

I'm a bit stuck...

I have a 'Reoccur Interval' dropdown and 'Reoccur Count' field in an 'Attendance' table for school kids. When I select 'Weekly' from the Reoccur Interval and then type in '4' into the Reoccur Count field, I want the system to duplicate that record 4 times, for the next 4 weeks using the 'Date' field. That's the easy bit which I am able to do. But I also want to halt execution and display an error alert if the user forgets to fill in the Reoccur Count field. So far, this is the structure..

function attendance_before_insert(&$data, $memberInfo, &$args){

//Check if Reoccurance Interval field has been selected
$reoccurtype = $data['reoccuring'];
$reoccurcount = $data['reoccurcount'];
if ($reoccurtype == 'Daily'){
if (!$reoccurcount){
//Halt execution and display error alert 'Reoccur Count field can not be left blank!'
} else {
//Insert the field
}
} else if ($reoccurtype == 'Weekly'){
if (!$reoccurcount){
//Halt execution and display error alert 'Reoccur Count field can not be left blank!'
} else {
//Insert the field
}
} else if ($reoccurtype == 'monthly'){
if (!$reoccurcount){
//Halt execution and display error alert 'Reoccur Count field can not be left blank!'
} else {
//Insert the field
}
}

return TRUE;
}

Any help with halting execution within the if condition and showing the alert would be really appreciated!

Post Reply