Forums

Event switcher [GH] problems

olaeblue 06 Jan, 2013
I can't get this to work as I expect so I'm looking for some help/advice.

I have a form. If I want to edit it I use &event=edit on the URL and with PHP then add the cf_id hidden field and another hidden field called 'event' with the value 'edit' in it. So far so good. However I want different actions depending on which event is active when you hit the submit button.

So On Submit I put an Event Switcher [GH] action (ordinary event switcher only has 2 states sucess or fail) with the following code.

<?php $event = $form->data['event'];
switch ($event) {
    case "edit":
        return 'event_a';
        break;
    case "delete":
        return 'event_b';
        break;
    default:
        return 'event_d';
}
?>


For each state I can then put different email and thanks messages if it worked, but it just seems to ignore the states & code and do a default db save. Why?
GreyHead 06 Jan, 2013
Hi olaeblue,

Please try replacing 'event' with 'eventx' or almost any other name. The parameter name 'event' is used by ChronoForms to identify the form event e.g. 'load', 'submit', 'ajax', etc. and so your value is either going to be overwritten by event=submit or ChronoForms is going to look for an 'On edit' event to run.

Similarly, avoid using 'task', 'option', 'view', etc.

Bob
olaeblue 06 Jan, 2013
Thanks. Rather obvious really :-)
This topic is locked and no more replies can be posted.