Max,
Thank you for your quick reply.
Here is what I did so far:
I have a php with name age_calculator. I placed it as first action in submit. Here is my php code that I'm using to calculate age based on the date of birth entered in the form:
// Simplify variables
$dob = $form->data['dob'];
//Calculate Age
//explode the date to get month, day and year
$dob = explode("/", $dob);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $dob[0], $dob[1], $dob[2]))) > date("md")
? ((date("Y") - $dob[2]) - 1)
: (date("Y") - $dob[2]));
$form->data['age'] = $age;
// Load appropriate event from event Switcher.
if ( $form->data['age'] >= 18 ) {
return 'adult';
break;
} else {
return 'young';
break;
}
Then I have event switcher, with following settings:
Data Provider: {var:age_calculator}
Events: adult,young
I have an event loader in each event that should load appropriate event.
Unfortunately, this form is running the first event (adult) every time no matter what the date of birth is. Here is my debug data:
Array
(
[option] => com_chronoforms6
[chronoform] => pps-0-age
[event] => submit
[dob] => 08/12/1971
[submit] =>
)
It seems like my php code is not calculating the age appropriately. I think I have a problem with how I'm calling the variables, but I'm not sure how. This is the same php code that I used in v5 and it worked perfect.
Attached is a screenshot of my Events for better clarification.
Thanks again. I love V6 and I don't want to go back to V5. I'm converting all my forms to V6