I have a form today CF v4 where I use Event-Switcher [GH]. Is the app for CF v5 similar to that.
I have this code:
In CFv4 it works but when I try to use the same code in CFv5 nothing happens.
//JeLu
I have this code:
<?php
$user =& JFactory::getUser();
$user_id = $user->id;
$pnr = '';
if ( isset( $form->data['pnr'] ) ) {
$pnr = $form->data['pnr'];
}
if ( !preg_match( "/^\d{8}\-\d{3}\w{1}$/", $pnr ) ) {
return 'event_b';
$form->errors[''] = 'My error message';
}
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__my_table`
WHERE `pnr` = {$db->quote( $pnr )};
";
$db->setQuery($query);
$rows = $db->loadObject();
$actual_user = $rows->cf_user_id;
$pnr_exist = $rows->pnr;
if ( $actual_user == $user_id) {
return 'event_a';
}
elseif ( $pnr_exist ) {
return 'event_d';
}
else {
return 'event_c';
}?>
In CFv4 it works but when I try to use the same code in CFv5 nothing happens.
//JeLu
Hi JeLu,
The main difference is that the CFv5 Event Switcher [GH] had a fixed list of four events event_a, event_b, . . . while the CFv5 Event Switcher lets you set your own list of events by putting the list in the Events box at the top, saving the action, re-opening it and clicking the Load Events button.
The ability to create your own events is really helpful in making forms simpler to understand!
If you add the list event_a,event_b,event_c,event_d then it should behave in the same way as the CFV4 version, Note: make a copy of your code just in case it gets lost when the events list is updated.
In your code you should also remove the two & from the =& lines as they are deprecated in more recent version.The $form->errors line may also need to be changed for CFv5.
Bob
The main difference is that the CFv5 Event Switcher [GH] had a fixed list of four events event_a, event_b, . . . while the CFv5 Event Switcher lets you set your own list of events by putting the list in the Events box at the top, saving the action, re-opening it and clicking the Load Events button.
The ability to create your own events is really helpful in making forms simpler to understand!
If you add the list event_a,event_b,event_c,event_d then it should behave in the same way as the CFV4 version, Note: make a copy of your code just in case it gets lost when the events list is updated.
In your code you should also remove the two & from the =& lines as they are deprecated in more recent version.The $form->errors line may also need to be changed for CFv5.
Bob
This topic is locked and no more replies can be posted.