I've always battled figuring out a tidy sustainable way to do pre-processing when doing an add form so that it is pre-filed, without hacking the generated code. The solution was easy.
The idea is scan a barcode or enter any other data, then a lot of values could be looked up from any other source, auto filling fields, making adding complex records easier.
Generate a blank page as a template (tick the box on the generate tab)
Rename this page, blankpage.php, to anything meaningful, example: add_a_scan.php
Edit this page, putting a form in it, making it post to your default add page, example itemadd.php (Be sure to enable security if required).
Test it (it will not work yet)
Now back to PHPMaker:
In my global code section I created a custom function:
function get_mypost($val) {
if ( isset($POST[$val]) && strlen(trim(@$POST[$val])) > 0 ) {
return(trim(@$_POST[$val]));
} else {
return('');
}
}
Now, in your add setup, add a default value as get_mypost("barcode")
This will automatically retrieve the value you posted from the previous page, once generated.
Likewise, based on the barcode, you can pre-fill other values into the add page. The sky's the limit.
Enjoy!