Hi. I've recently purchased AppGini for our Charity and would like some help understanding how to ADD several FIELDs together in order to show the total in a separate FIELD.
Example:
FIELD4 = FIELD1 + FIELD2 + FIELD3
I'm using version 5.41. I'm not an expert so any help would be appreciated.
The dml files reads like this..
$data['FIELD4] = makeSafe($_POST['FIELD4']);
if($data['FIELD4'] == empty_lookup_value){ $data['FIELD4'] = ''; }
Auto Field Calculation
Re: Auto Field Calculation
It's all done in the table specific files in "hooks" folder. http://bigprof.com/appgini/help/advance ... ific-hooks
Hook files are not overwritten if you need to regenerate your Appgini application (say if you upgrade the version or add another field/table). That way, no need to edit any generated Appgini files and your hook files will still work.
See specific example code to add before updating the record here: http://bigprof.com/appgini/help/advance ... ore_update
In your case:
or depending on your circumstances, you might need to apply the code to the before_insert, after_insert or after_update hook function. Read the hooks examples for explanations. Here's your arithmetic operators: http://php.net/language.operators.arithmetic
Hook files are not overwritten if you need to regenerate your Appgini application (say if you upgrade the version or add another field/table). That way, no need to edit any generated Appgini files and your hook files will still work.
See specific example code to add before updating the record here: http://bigprof.com/appgini/help/advance ... ore_update
In your case:
Code: Select all
function tablename_before_update(&$data, $memberInfo, &$args){
// calculate total of field 1 + field 2 + field3
$data['field4'] = $data['field1'] + $data['field2'] + $data['field3']);
return TRUE;
}