Forums

Load next form based on variable?

jnobel 26 Jan, 2012
Hi, thanks for the great and powerful v4 !

I've got a chain of forms to be filled in, some only need to be filled in some cases.
This depends on what radio button was clicked in the first form.
So it goes something like this:

Form1 -> radio1==1 ====> On Submit: Load form 2
Form1 -> radio1==2 ====> On Submit: Load form 3 instead

So, Is it possible to do a Load Form depending on the value of a variable in a form?
I'd like to avoid javascript solutions if it is natively possible.
It would be really poweful if this was possible.

Another solution would be to use custom code after the submit, but I don't know what code to insert to load the next form ....

Anny help would be greatly appreciated.
Kind regards,
Johan
jnobel 26 Jan, 2012
I just realized this would be easy if the Utilities/"Show Form" action supported a PHP eval of the "Form Name", then I could dynamically load the appropriate form...

I don't suspect it works that way, but I'll try
GreyHead 26 Jan, 2012
Hi jnobel,

You can do this in several ways. You can use the ReDirect URL & ReDirect User actions, a Custom code action, or my custom Event Switcher [GH] action.

Which is best depends on the complexity of what you need to do. If you can build the ReDirect URL directly from the Form Data then that's the simplest way to go. If you need to process code then a Custom action with $mainframe->redirect(); will work OK; if you have multiple choices then the Event Switcher becomes useful.

In any case you should probably either save the current data using s DB Save action, or temporarily store it in the Session with a Data to Session action.

Bob
jnobel 26 Jan, 2012
Thanks Greyhead!,

I'll give all options a try.
I completely forgot about the possibility to use actions (You can write your own I think?)
That is also a possibility of course.

You are a very great resource on the Chronoengine forum, helping out so many people!
GreyHead 26 Jan, 2012
Hi jnobel,

You can write your own actions - it takes a bit of work but if you copy an existing simple action and go step by step it's not too difficult.

Bob
jnobel 26 Jan, 2012
Thanks again Bob !

I used your action as a starting point an now it works like a charm.
I think those actions are the most powerful feature of Chronoforms.

Kind regards,
Johan
This topic is locked and no more replies can be posted.