I'm having this problem in other big and complicated form, but recreated in smaller scale.
What I have is several parts (layouts) in form, which should be displayed in different cases, all layouts sets PageType to "Standalone". See screenshot:

in load's Actions I have simple Read Data, which reads users from DB, and then Loop Event which starts with trivial php, which looks into users's ID number and if it's less than 700, sets some data:switcher value to "1" , otherwise "2":

and this is the result:

As you can see, the code works well and returns correct numbers 1 or 2.
But Event Switcher somehow doesn't actually switches events, it somehow MIXES results when the second choice should be selected
Am I doing something wrong?
How to solve this mystery?
form file attached. depending on your Joomla actual state you may want to change "700" in php code to some other number to split your users id numbers.
EDITED: Also if testing, you're going to need to choose correct table from your db, because they all have unique prefixes!
[file=12716]test_event_switcher_28_Feb_2020_00_08_08.cf6bak[/file]
What I have is several parts (layouts) in form, which should be displayed in different cases, all layouts sets PageType to "Standalone". See screenshot:

in load's Actions I have simple Read Data, which reads users from DB, and then Loop Event which starts with trivial php, which looks into users's ID number and if it's less than 700, sets some data:switcher value to "1" , otherwise "2":
if ($this->_vars['loop_event5']['row']['Data1']['id'] < 700) {
$this->data['switcher'] = '1';
} else {
$this->data['switcher'] = '2';
}
// some output to check if code works correctly:
echo ('');
var_dump ($this->_vars['loop_event5']['row']['Data1']['id'] , $this->data['switcher']);
echo ('');and after php but still inside Loop event there is Event Switcher with following settings:
and this is the result:

As you can see, the code works well and returns correct numbers 1 or 2.
But Event Switcher somehow doesn't actually switches events, it somehow MIXES results when the second choice should be selected
Am I doing something wrong?
How to solve this mystery?
form file attached. depending on your Joomla actual state you may want to change "700" in php code to some other number to split your users id numbers.
EDITED: Also if testing, you're going to need to choose correct table from your db, because they all have unique prefixes!
[file=12716]test_event_switcher_28_Feb_2020_00_08_08.cf6bak[/file]
OK, here is quick workaround to avoid using Event Switcher - use Switcher Area in Views instead:

And this is Event Loot in Actions without Event Switcher:

But still - Event Switcher doesn't work as it intended to. Hope this bug will be fixed soon

And this is Event Loot in Actions without Event Switcher:

But still - Event Switcher doesn't work as it intended to. Hope this bug will be fixed soon
"1" might be the same as "true" so try something else - "one" / "two" for example.
I tried many combinations with same result. one/two layoutone/layouttwo, true/false, 1/2, 0/1, - result is same.
Instead of $this->data['switcher'] try calling your PHP block 'switcher', and RETURNING the value, then using {var:switcher}
OR use $this->data('switcher', $value, true) and then {data:switcher}
OR use $this->data('switcher', $value, true) and then {data:switcher}
problem is not in php - you can see on screenshots it outputs correct values.
Weird. Switching correctly for me.
For future reference though the correct syntax is
For vars: $this->get('varname', 'an optional default value if varname doesn\'t exist')
$this->set('varname', 'value')
For data: $this->data('dataname', 'an optional default value if dataname doesn\'t exist')
$this->data('dataname', 'value', true)
You could also use the If Conditions instead of PHP + Event Switcher
For future reference though the correct syntax is
For vars: $this->get('varname', 'an optional default value if varname doesn\'t exist')
$this->set('varname', 'value')
For data: $this->data('dataname', 'an optional default value if dataname doesn\'t exist')
$this->data('dataname', 'value', true)
You could also use the If Conditions instead of PHP + Event Switcher
$this->set('varname', 'value')This construction didn't ever work for me. I've seen this lots of times here on forum and in CF manual, but it just doesn't work. probably, it's because php v 7.2?
Nothing to do with the PHP version, that's a Chronoforms function. And it sets a {var:} not a {data:}
And it sets a {var:} not a {data:}Thanks, I know the difference. I just once spent several hours trying to figure out working functions and passing variables (php <> CF) and have no time to spend for more experiments recently.
As usually - great component with rapid updates that brake all the workflow, and almost completely missing documentation..
Actually, as long as I tried to use Event Switcher inside Event Loop, this bug is related to:
http://www.chronoengine.com/forums/posts/t108204/event-switcher-and-if-conditions-doesnt-work-inside-loop-event
http://www.chronoengine.com/forums/posts/t108204/event-switcher-and-if-conditions-doesnt-work-inside-loop-event
This topic is locked and no more replies can be posted.
