nuRunPHPHidden() runs a Procedure on the server that contains PHP code. To pass data to the procedure, use nuSetProperty(). This sets the current Form's property and is retrieved as a Hash Cookie when the Procedure runs.
-
First, create a Procedure: Tab Builders -> Procedure -> Add if you don't have one at hand.
-
Code: e.g. Procedure_Test
-
Description: Enter a description for the procedure (E.g. Testing )
-
Paste this PHP code
// Retrieve a single hash cookie (see Example 1)
$param = "#param#"; // 'test single parameter'
// Retrieve a hash cookie that contains multiple data (see Example 2)
$params = json_decode(base64_decode('#params#'));
$info1 = $params->info1; // 'a'
$info2 = $params->info2; // 'b'
$info3 = $params->info3; // 'c'
-
Save
-
Add this JavaScript Code to your form’s Custom Code field:
function base64encode(str) {
let encode = encodeURIComponent(str).replace(/%([a-f0-9]{2})/gi, (m, $1) => String.fromCharCode(parseInt($1, 16)))
return btoa(encode)
}
function runPHPHiddenWithParams(procedure, params) {
nuSetProperty('params', base64encode(JSON.stringify(params)));
nuRunPHPHidden(procedure, 1);
}
Create a Button with a custom click event to run the Procedure Procedure_Test. At the same time the property param with value 'test single parameter' is set.
nuSetProperty('param', 'test single parameter'); nuRunPHPHidden('Procedure_Test', 1);
Create a Button with a custom click event to run the Procedure Procedure_Test. Multiple "parameters" are passed to the Procedure.
runPHPHiddenWithParams('Procedure_Test', {info1: 'a', info2: 'b', info3: 'c'});