Forums

Chaining

gaze 18 Feb, 2009
Hi there,

I'm new to this forum and i have a question.
I searched the forum for chaining forms but i cannot find it so ip presume it's not asked earlier.

Can anyone tell me if and how it is possible to chain different forms together?
If this is possible, then the next question would be, how to get the data of the chained forms as one result?

Thanks for your time,

Kind regards,
Johan van Leur
GreyHead 18 Feb, 2009
Hi Johan,

There are several thread on multi-page or multi-tab forms - I think that this is probably what you are looking for.

Bob
gaze 18 Feb, 2009
Hello Bob,

I checked the search again and found some topics on multi page forms but i think this does not suit my needs.
The next question is:

Say, for example i have a form with a 4 radiobuttons on it.
When i click the first button the next form should be form_1
but when i click the fourth button, the next form should be my_next_form_4,
Also, there should be functionality to go back to the previous form when applicable.

In this case i could setup a dialog with the end-user to ask certain questions and questions to follow
In the end, after the last form, all of the data should be posted as one or maybe as XML data.

You think this can be done with this product?
or is there a way to "hack" it in?

Thanks for your time,

Kind regards,
Johan van Leur.
GreyHead 18 Feb, 2009
Hi Johan,

You can do this without 'hacking' the extension but it will take some coding.

I would do this as a multi-page form where the logic of what is displayed and how the responses are handled is managed by PHP in the Form HTML and the OnSubmit code boxes.

In pseudo-code the Form HTML goes something like this:
<?php
if ( there is no radio-button value ) {
   // show the radio buttons
} else {
  switch (on radio button value ) {
    case button1:
      // show some more code 
      break;
    case button2:
      // show some other code
      break;
 . . .
}
?> 
The logic here can be as complex as you like!

In the onsubmit code you need something similar then use showform($_POST); to redisplay the form html and pass the values in the $_POST array (or some other array if you prefer).

Alternatively, you could build the whole form in JavaScript in a singel form but this is IMHO more complex.

Bob
gaze 02 Mar, 2009
Hi,

Yes, i see how it should work but there is only one problem. My clients have to create the multi-page forms themselves and they are not able to write the needed code behind the forms. So it should be something simle to work with.

Maybe you could add some features for native multi page support.

Kind regards,
Johan van Leur
GreyHead 02 Mar, 2009
Hi Johan,

You are looking for something more like a custom extension there if you want something that will 'simply' create multi-page forms.

I've no idea what future plans Max has for ChronoForms; multi-page support is tricky as each client seems to have different needs :-( Something simple might get built in - for tabbed forms for example - but I doubt that it will meet your needs here.

Bob
Max_admin 02 Mar, 2009
Hi Bob, Johan,

I have plans to make multi page forms but as Bob said, every user has his own needs, the only challenge I know with multipage forms is reloading the data for the passed pages, which will be tricky and may require using PHP code by users, I will look into the issue soon.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gaze 03 Mar, 2009
Hi Max,

Maybe it's an idea to create some navigational controls along with the form controls.
Also you could create some "selector" to choose which form to load next.

Kind regards,
Johan van Leur
Max_admin 03 Mar, 2009
Hi Johan,

That's fine, but when you navigate to another form which you have already passed by before then you expect to find your data still there, here is the tricky part!😑

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gaze 17 Mar, 2009
Hi Max,

I don't think it's a problem that the data is allready there, Why would i use one form twice in the same dialog?
I hope you find the time to implement this soon otherwise i have to go and look for some other solution.

I also posted a thread on prefilling the formvalues, can you tell me if there is any progress on that part?

Thanks again for your time,

Kind regards,
Johan van Leur
Max_admin 17 Mar, 2009
Hi Johan,

most of the multi page forms will need to have the ability to jump between steps, I'm sure that at least 80% of users will ask for this!

I also posted a thread on prefilling the formvalues, can you tell me if there is any progress on that part?



I will answer at that thread then!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ajw3208 08 Jun, 2009
H Max,

To restart this thread base on the new V3.1 RC5.0 just released.

I having reasonable success with the multipage capability. Using the normal PHP $_POSt to recover information submitted in the previous form is working well. This is a really strong plugin and very useful.

What I am struggling with is the following use case;

After the final form in the multiform chain is submitted,the following code -exhibit#1 (which is located in the "submit after email" section) is used to cause the "system" to loop back to the "mother form" called regoholder in the code below. This is successful as the first form in the multipart chain then shown. so far so good. This loopback is needed as it is a multiperson rego form, but with a common rego number and the number must be common to all people being regsitered in that session (e.g. all members of one family have a common rego number)

The issue is that there are input values that are passed into the $_POST array for use in the first form of the "new" chain, that are lost when the mulitpage chain is executed. The required values are being setup correctly (see code below in exhibit#2) in the final form in the chain. (It may not be pretty code but it works 😑). Sadly, none of the values are passed back into the chain and onto the first form. Its like the "mother" form has no way of grabbing the $_POST values.

I have tried putting code into both the HTML section and the "after email section" to grab and subsequently reset the values I need but to no avail. I ahve also tried publishing the "mother" form and this has not effect.

Any thoughts on how to get around this?

BTW.

Terrific extension. Stable, predictable, and with heaps of features. An outstanding effort.

exhibit#1 submit after email code
<?php
$action = JRequest::getString('rf4sBtn');
if (strcasecmp($action, 'Next') != 0) {
  //Redirect to some other url...
  $t =& JFactory::getApplication('site');
  $t->initialise();
  $t->redirect('index.php?option=com_chronocontact&chronoformname=regoholder');
}
?>


exhibit#2 - input value setup code
<input type=hidden name="changedDetails" value=<?php echo $_POST["changedDetails"];?>>
<input type=hidden name="playerRegNum" value=<?php echo $_POST["playerRegNum"];?>>
<INPUT TYPE=HIDDEN NAME="playerRegNumCtr" value=<?php echo $_POST["playerRegNumCtr"];?>>
GreyHead 08 Jun, 2009
Hi ajw3208,

I haven't tried to think through the implications of looping back.

Are you saving the data in a table before you go back to step 1? If so, you could save the regno in a user session and use that in step 1 to do a database query and load any pre-saved info you need. (If there's no regno -- then you are starting a new family group.)

I'm also curious that you are looing back to the mother and not to step 1. Is this the right thing to do? (I really have no idea.)

Bob
ajw3208 09 Jun, 2009
Hi Bob,

I loop because I need each rego process to follow exactly the same flow every time (and there may be up to 10 rego process needed). Multipage is the controlling entity of that flow.

My logic (as flawed as it is) is that the "mother" form is a natural entry point and is the flow control to all subsequent forms. Dropping into the first form called by "mother" would break the automated flow capability that multipage brings.

Happy to be corrected if I'm not using Multipage properly.

aj
GreyHead 09 Jun, 2009
Hi aj,

You probably know more about this than I do, so don't change anything on my account.

Bob
ajw3208 10 Jun, 2009
Hi Bob,

I have figured out why the $_POST array is being dropped when the loop back to the "mother" form happens. It also happens if we loop to the first form rather than the "mother" form.

The code below is the culprit. It is doing EXACTLY as it is supposed to. It is redirecting rather than creating an alternate form action URL, thus dropping the $_POST array during the redirect. Foolishly in my original post ,I didn't specify I needed an alternate form action so I got redirect code. (silly me)

What is the best way to modify the code below to create an alternate form action. Use case is

press submit btn #1 on form4 and on submit form action = ......regoform5
press submit btn#2 on form 4 and on submit form action = .......regoholder (the loop action). This is the one that needs to maintain the $_POST array

regards,

aj

<?php
$action = JRequest::getString('rf4sBtn');
if (strcasecmp($action, 'Next') != 0) {
  //Redirect to some other url...
  $t =& JFactory::getApplication('site');
  $t->initialise();
  $t->redirect('index.php?option=com_chronocontact&chronoformname=regoformholder');
}
?>
Max_admin 15 Jun, 2009
Hi aj,

I'm not following the whole post here but if you will lose the form post url then you may want to save the posted data in a session variable!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.