Hello-
I need to be able to trigger a save data action only if certain conditions are true from the form data (age of user is 18 or older). Chronoforms 7 has Run Conditions for this. What do I use for Chronoforms 8?
using a PHP events behavior, you do your conditions check using PHP code, check for data with $this->data("field_name"), variables with $this->get("var_name")
Max-
Can you be so kind as to elaborate on this? For example I have a custom PHP action that looks at a checkbox and returns T/F. How do I link that to my Save_Data10 action so that it only saves the data if the checkbox is checked? I see in the PHP an "Event" behavior is that what is used or something else. Thank you in advance for your time.
Hi mgergel
After you enable the Events behavior in PHP and define your events as T,F, save the form to rebuild the PHP action with events, then you can put your Save Data action in T event
Run conditions added to v8.0.24
Hi, I’m trying to use Run Conditions in the form’s onLoad section. Basically, with PHP I check whether a value exists in the DB and return a boolean. I was thinking of storing this value in a variable, as in this example:
...
$db->setQuery($query, 0, 1);
$exists = (bool) $db->loadResult();}
catch (\Throwable $e) { // On any failure, keep $exists as false}
// Make the result available locally and to ChronoForm
$this->data("current_year_exists") = $exists;
// Fallback output when ChronoForm form object is not available
echo $exists ? "LOAD COMPLETED FOR YEAR " . date('Y') : "UPLOAD ENABLED FOR YEAR " . date('Y');
Right after the PHP action I want to use a Run Condition to show or hide a Container/Grid. But when I enter the variable name current_year_exists and the expected value, it doesn’t work. Where am I going wrong

What is the value of the current_year_exists variable in the debug Vars array after your code runs ?
Hi Max, the variable doesn’t show up in the debug, so it looks like it isn’t being instantiated.
The value I expect is 0/1, the same value stored in the $exists variable.
For simplicity, I created a test form with a simple PHP module in onLoad; the form does nothing other than this:
$exists = 1;
$this->data('current_year_exists', (int)$exists);
echo " | current_year_exists " . $this->data('current_year_exists') . " | exists " . $exists;
The output I’m getting is: | current_year_exists | exists 1.
Below is the debug screenshot.

Hi Max, I did some further digging and figured out why I couldn’t initialize the current_year_exists variable.
The assignment has to be done with
$this->set("current_year_exists", $exists);
while reading uses
$this->get('current_year_exists');.
With this approach, after my PHP block runs I can see the variable’s values in the debug
Vars
Array
(
[app_active_page] => 1
[current_year_exists] => 1
[php2] => NULL
)
but I still can’t get the Run Conditions to work, which I’ve defined as follows:

Hi dct
Great, now you have to use {var:current_year_exists} to get the value of the var and use it in the comparison
