Forums

Event switcher custom action help

mcarbone 15 Mar, 2013
Hi,

I have a small form that should take the user to a specific place on the website based on two responses given in the form. Specifically, the user selects a date (dropdown) and a time (radio button). Once the user submits the form, it should go to the specific excursion page to purchase tickets. I am using Event Switcher to do this, but I am having difficulties getting it to work. It must be something with my code. 😢

Here's what I've done:
1. I've added an "event switcher" action to the On Submit event. Here's the php for the action:

<?php
switch ($form->data['excursion_date'],$form->data['departure_time']) {
  case ('July27','1pm'):
    return 'event_a';
    break;
  case ('July27','3pm'):
    return 'event_b';
    break;
case ('July28','11am'):
    return 'event_c';
    break;
 default:
    return 'event_d';
 
}
?>

P.S. I've also tried:

switch ($form->data['excursion_date' && 'departure_time']) {
case ('July27' && '1pm'):
    return 'event_a';
    break;
  case ('July27' && '3pm'):
    return 'event_b';
    break;
case ('July28' && '11am'):
    return 'event_c';
    break;
 default:
    return 'event_d';


In the first code set, I just get a submitted form - essentially nothing happens, but the form is blank and the URL shows it was submitted / processed. The second code set I only get to the first date (july 27 at 1pm), no matter what I pick. 😲

In events a-d, I added a redirect user action to a specific URL. I also added a show stopper to Event d, each event (a-d), and the event switcher...all separately of course...nothing worked. I am not exactly sure where the show stopper needs to go though.

I am only trying this with the first 3 cases (July 27 at 1pm, July 27 at 3pm and July 28 at 11am), so right now I only have one event switcher, but in the end, I will have at least 3. Can someone tell me if I am at least on the right path.

specs:
Joomla v 2.5.8 and CF v4

location of the form: http://dev.lionstrainrides.com

Thank you so much for your help! Always greatly appreciated.

MC
GreyHead 15 Mar, 2013
Hi mcarbone,

I don't think that sticking a comma between two PHP variables will work :-(
($form->data['excursion_date'],$form->data['departure_time'])
and even if it did the result wouldn't have quotes around the comma:
('July27','1pm')

You could try something like this:
<?php
$date_time = $form->data['excursion_date'].','.$form->data['departure_time']
switch ($date_time) {
  case 'July27,1pm':
    return;
. . . 

Bob
mcarbone 21 Mar, 2013
Hi Greyhead,

Thank you so much for your valued support. It worked! My php concatenation skills leave a lot to be desired. 😶

For others, here's what I did:
<?php 
$date_time = $form->data['excursion_date'].','.$form->data['departure_time'];

switch ($date_time) {
    case "Jul27,1pm":
        return 'event_a';
        break;
    case "Jul27,3pm":
        return 'event_b';
        break;
    case "Jul28,11am":
        return 'event_c';
        break;
    case "Jul28,1pm":
        return 'event_d';
        break;
}
?>
This topic is locked and no more replies can be posted.