Chronoforms Version: v4 RC 3.5 (but I think it's the same in 3.5.1).
In a form I have used 12 containers, created in different steps.
After I finished adding that containers, on frontend the form was displayed correctly, but when accessing Form Wizard in control panel, the script stay running forever, ending with a PHP timeout.
I debugged the script and found that the problem was in function getContainerOutput of file administrator/components/com_chronoforms/views/form_wizard.php.
I was able to solve this problem creating a better recursive function, and an utility function to create a temporary array:
Then, in line 546 of form_wizard.php, I have called this code:
Instead of:
It seems to works correctly and it's also more good in performance.
I'm also attaching the complete modified file. Can you include this fix in next release?
Stefano Bagnatica
In a form I have used 12 containers, created in different steps.
After I finished adding that containers, on frontend the form was displayed correctly, but when accessing Form Wizard in control panel, the script stay running forever, ending with a PHP timeout.
I debugged the script and found that the problem was in function getContainerOutput of file administrator/components/com_chronoforms/views/form_wizard.php.
I was able to solve this problem creating a better recursive function, and an utility function to create a temporary array:
function buildContainersArray($wizcode) {
$arr = array();
foreach ($wizcode as $key => $element) {
$tmp = explode("_",$key);
$fieldid = intval($tmp[1]);
$contid = intval($element['container_id']);
if ($contid!=$fieldid) {
if (!isset($arr[$contid])) $arr[$contid] = array();
$arr[$contid][] = $fieldid;
}
}
return $arr;
}
function buildContaintersOutput(&$containers_outputs, &$childs, $id=0) {
if (isset($childs[$id])) {
foreach ($childs[$id] as $child) {
$containers_outputs[$child] = buildContaintersOutput($containers_outputs, $childs, $child);
$containers_outputs[$id] = str_replace('<!--CONTAINER_ELEMENTS-'.$child.'-->', $containers_outputs[$child], $containers_outputs[$id]);
}
}
return $containers_outputs[$id];
}
Then, in line 546 of form_wizard.php, I have called this code:
$containers = buildContainersArray($wizardcode);
echo buildContaintersOutput($containers_outputs, $containers);
Instead of:
echo getContainerOutput($containers_outputs[0], $containers_outputs);
It seems to works correctly and it's also more good in performance.
I'm also attaching the complete modified file. Can you include this fix in next release?
Stefano Bagnatica