Page 1 of 1

nuRunPHPHiddenWithParams

Posted: Thu Nov 03, 2022 9:20 am
by nuno
Hello, I´m new to nubuilder and i'm asking some guidance in this subject:

I'm trying to run a procedure with "nuRunPHPHiddenWithParams": Starting the procedure seems to work fine since the "#param#" is created and displayed in the form info table:

param "BxZwYXJhbTEWAxYxMjM0NTYWAhZwYXJhbTIWAxYyMzE2NTQ1NDQ1NjQWBw=="

inside the php code the base64_decode("#param#") also seems to work fine since:

$param=base64_decode('#param#');

nuDebug($param);

returns [0] : param1123456param2231654544564

what doesn't work is the $param=json_decode($param,false) since i'm unable to retrieve anything from the object with:

§par1=$param->param1

and also $param=json_decode(base64_decode('#param#'); apparently doesn't create the object.

I separated the "base64_decode" and "json_decode" functions for debugging purposes only.

Any sort of comment or suggestion would be very appreciated.

Re: nuRunPHPHiddenWithParams

Posted: Thu Nov 03, 2022 9:42 am
by kev1n
Hi,

nuBase64encode() is somehow flawed. Try replacing nuRunPHPHiddenWithParams() with

Code: Select all

function nuRunPHPHiddenWithParams(i, paramName, paramValue, rbs) {
	nuSetProperty(paramName, btoa(JSON.stringify(paramValue)));
	nuRunPHPHidden(i, rbs);
}
My test:

JS:

Code: Select all

nuRunPHPHiddenWithParams('test_procedure', 'param', {param1: '12345'}, 0); 
PHP:

Code: Select all

$param = json_decode(base64_decode('#param#')); // retrieve the parameters
$param1  = $param->param1;

nuDebug($param1); // returns 12345

Re: nuRunPHPHiddenWithParams

Posted: Thu Nov 03, 2022 10:10 am
by nuno
Thanks for the help. worked like a charm.