Setting a condition for running validation causing error
Context: Development website on Localhost with PHP8.1 running J4.2.8 and Fabrik4gamma. Upgraded copy of live J3.10 website on which Fabrik runs without problem. Fabrik used in backend only, to input data into an events database.
The user selects a venue from a dropdown list using a databasejoin plugin.
Please Select is activated and has the value 0.
To enforce selection of a venue from the dropdown an isgreaterorless than validation is run, checking that the value is greater than 0.
This works fine if set to always validate.
However, as well as picking a value from the dropdown, the user can leave the dropdown value as Please Select and instead type in a one-off value in a field called eventlocation (this uses a field plugin). In this case, there is no need to run the validation on the venues list dropdown and I have set a condition whereby the validation runs only when the eventlocation field is empty:
With this condition in force, when the user tries to save a new or edited record in form view, the following error occurs:
0 syntax error, unexpected token ";", expecting "function" or "const"
Stack trace points the problem to a temporary file generated by Fabrik, eg JROOT\tmp\fabrik\FabrikEval_ddbb531f50144827ee3ab83617007333:17
The content of this temporary file is:
Screenshots follow:
Context: Development website on Localhost with PHP8.1 running J4.2.8 and Fabrik4gamma. Upgraded copy of live J3.10 website on which Fabrik runs without problem. Fabrik used in backend only, to input data into an events database.
The user selects a venue from a dropdown list using a databasejoin plugin.
Please Select is activated and has the value 0.
To enforce selection of a venue from the dropdown an isgreaterorless than validation is run, checking that the value is greater than 0.
This works fine if set to always validate.
However, as well as picking a value from the dropdown, the user can leave the dropdown value as Please Select and instead type in a one-off value in a field called eventlocation (this uses a field plugin). In this case, there is no need to run the validation on the venues list dropdown and I have set a condition whereby the validation runs only when the eventlocation field is empty:
Code:
if ('{tbl_events___eventlocation_raw}'=='')
{
return true;
}
else
{
return false;
}
With this condition in force, when the user tries to save a new or edited record in form view, the following error occurs:
0 syntax error, unexpected token ";", expecting "function" or "const"
Stack trace points the problem to a temporary file generated by Fabrik, eg JROOT\tmp\fabrik\FabrikEval_ddbb531f50144827ee3ab83617007333:17
The content of this temporary file is:
Code:
<?php
defined('_JEXEC') or die;
class FabrikEvalClass_c6921bd83221520266ce19cf3b82c941{
function doExecute($vars, $thisVars) {
foreach ($vars as $varKey => &$varValue) {
${$varKey} = &$varValue;
};
if ('{tbl_events___eventlocation_raw}'=='')
{
return true;
}
else
{
return false;
?><?php
}
};
Screenshots follow: