Setting a condition for running validation causing error

Status
Not open for further replies.

BasilC

Member
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:

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:

stacktrace.png

validation.png

stacktrace.png
validation.png
condition.png
 
After posting the above, I spotted the Gamma1 release and have installed it. It hasn't fixed the issue. (Not a criticism - I'm very impressed and grateful for the enormous amount of work that it clearly going on to get Fabrik J4-compatible.)
 
So it is, how could I have not spotted that?!? What an idiot!

I've corrected that, but now the condition isn't being applied properly.

If I delete the condition, the validation works and forces me to select from the dropdown.

When I restore the condition (with all curly brackets in place this time), the form lets me leave Please Select in the dropdown and leave eventlocation blank, which it shouldn't do.

I've looked in phpmyadmin and the dropdown value is set to 0 and eventlocation is blank. So the validation should run, but it isn't running.
 
Ok.
It seems at the moment (F4, gamma1) at least in conditions the element placeholders don't support _raw. The non-raw placeholders contain the raw values.
 
Ok.
It seems at the moment (F4, gamma1) at least in conditions the element placeholders don't support _raw. The non-raw placeholders contain the raw values.
Thanks, deleting _raw has fixed that one. (In this case, there was no real reason to specify _raw anyway, as the non-raw and raw values should be identical.)
 
Ok.
It seems at the moment (F4, gamma1) at least in conditions the element placeholders don't support _raw. The non-raw placeholders contain the raw values.
All, is this true only in gamma, or does it happen in previous 4.0 releases? Does it happen on F3?

The placeholder substitution code hasn't changes since 3 so I would be surprised if this worked in it.
 
The values used in the validations are in $_REQUEST. In F3 you'll find 'element' and 'element_raw' (holding formatted and raw value), in F4 (gamma and also beta) there's only 'element' (holding the raw value).
So it's not the replacement but setting the $_REQUEST array (input) somewhere.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top