This one took me a while to figure out. You can add custom PHP code to be executed before the Web Entry form is generated by editing your
processmaker/shared/sites/{workspace}/public/{process-id}/{step-id}.php file.
Any variables that you want to pass to the Dynaform when it is generated need to be set as in the ['APP_DATA'] element in the array that is passed to the new pmDynaform() object.
Here is a code example. Change the code from:
Code: Select all<?php
global $_DBArray;
if (!isset($_DBArray)) {
$_DBArray = array();
}
$_SESSION["PROCESS"] = "5384231895a8df57b0b5bd0064144777";
$_SESSION["CURRENT_DYN_UID"] = "2809796415a8df5b576c316091834096";
$G_PUBLISH = new Publisher();
G::LoadClass("pmDynaform");
$a = new pmDynaform(array("CURRENT_DYNAFORM" => "2809796415a8df5b576c316091834096"));
To:
Code: Select all<?php
G::LoadClass("pmFunctions");
$ratingList = array(
array('', "--select--"),
array("good", "Good" ),
array("bad", "Bad" ),
array("ugly", "Ugly" )
);
$userList = array();
$sql = "SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) AS FULL_NAME FROM USERS";
$aUsers = executeQuery($sql);
foreach ($aUsers as $aUser) {
$userList[] = array($aUser['USR_UID'], $aUser['FULL_NAME']);
}
$sql2 = "SELECT PRO_TITLE AS processTitle FROM PROCESS";
$processList = executeQuery($sql2);
$aCaseVars = array(
'ratingList' => $ratingList,
'userList' => $userList,
'processList'=> $processList
);
global $_DBArray;
if (!isset($_DBArray)) {
$_DBArray = array();
}
$_SESSION["PROCESS"] = "5384231895a8df57b0b5bd0064144777";
$_SESSION["CURRENT_DYN_UID"] = "2809796415a8df5b576c316091834096";
$G_PUBLISH = new Publisher();
G::LoadClass("pmDynaform");
$a = new pmDynaform(array("CURRENT_DYNAFORM" => "2809796415a8df5b576c316091834096", "APP_DATA" => $aCaseVars));
This code sets 3 variables which populate the list of options in two dropdown boxes and the rows in a grid in the Web Entry form. To test it, import this process:
(30.95 KiB) Downloaded 219 times