Forums

Browser back button and multipage form [Mostly solved]

stefanmarx 24 May, 2011
Hi,

I am working on a 5 page multipage form for the booking of a conference and it is working quite well, at least when it is used the supposed way ;-). On the last form page there is only some php code which calculates a price based on form input, displays it and puts it via a hidden field into the database (I know, bad design, but it gets checked manually anyway, and its not for tech savvy users, but a very small closed user group). The calculated price is converted into a variable {price} in the mother forms on submit-code section which is used then in the email, that is send to the user. So far, so good. Did several Tests, all worked fine (for me).

I've put it productive and recognized users that have no price in the database. However, I got no complaints about missing price information and tried to find out what happened. I managed to provoke the sam effect, when I fill out all the form, get to the last page and press the browsers back button to get to a former page, maybe to correct some value or the like, and then use the child forms submnit button. Then the email will be sent, with the correct price in it, but its not getting into the database.

How can I change this disturbing behaviour? Will the navigation feature get me out of this mess?

Cheers, Stefan
GreyHead 24 May, 2011
Hi Stefan,

I'm not sure; browser back buttons are a problem :-(

I think that the answer is (a) to add Steps Navigation so that you provide a back button on the form and (b) to add more checks to the child forms so that data is not submitted directly from them.

I'm not sure how clicking the submit button on a child step is submitting the form though? (That may just be that I don't understand the multi-page process well enough.)

Bob
stefanmarx 24 May, 2011
Hi,

hm. I will give a try to the navigation links and try to make them buttons.
What exactly happens when I do not have a submit action in a child form, but navigation links only? is the data still collected into an array that gets posted on the motherforms submit? I will try that out.

(-; "bloody users"(tm) ;-)

Cheers,

Stefan
GreyHead 25 May, 2011
Hi Stefan,

The navigation links (with Steps Navigation enabled) allow you to move freely between child forms while preserving the data. The submit button does the same but automatically moves the user to the next child form in sequence.

Bob
stefanmarx 25 May, 2011
Hi,

ok, I have replaced the submit buttons with navigation links. Now I can navigate between the form steps but do not get the data from one child form to the next one, and if i navigate back, the already filled in fields are empty. Also I do not get an alert, if I forget to fill in obligatory fields.

I think I miss(mess?) ;-) something here... Can you point me to a working example?

Cheers, Stefan
GreyHead 26 May, 2011
Hi Stefan,

Did you use the Steps Navigation option in the Multi-Page plug-in setup?

From the Help tab

Select Steps Navigation if you want to be able to navigate directly to form steps using urls with the &cfformstep parameter e.g. index.php?option=com_chronocontact&chronoformname=test_form_8&cfformstep=2



Bob
stefanmarx 26 May, 2011
Hi,

yes, I did. I wrote this links into the html form code:


<div class="form_item">
  <div class="form_element cf_heading">
    <h1 class="cf_text">
<a href="index.php?option=com_chronocontact&chronoformname=online_anmeldung&cfformstep=1">Zurück zu Schritt 1</a> | 
<a href="index.php?option=com_chronocontact&chronoformname=online_anmeldung&cfformstep=3">Weiter zu Schritt 3</a>

</h1>
  </div>
  <div class="cfclear"> </div>
</div>


With only the motherform selected I enabled page navigation in the multipage plugin.

When I tested this out before removing the submit button code, I filled in some values on the first page, submitted it with the button, then changed the url in the browser manually to &cfformstep=x and jumped between the child forms back and forth manually whith changing the x to the desired page. On that page where I had submitted the values, the values re-appeared.

While searching through this marvellous forum, I stumbled upon the code to preserve the values into an array, this is also mentioned in the book. But I did not need it between the single pages, I could access all submitted fields from every page where I needed them with the
$session =& JFactory::getSession();
$posted = $session->get('chrono_formpages_data_online_anmeldung',
array(),
md5('chrono'));
code. Do I need to implement something similar on every child form?

Cheers, Stefan
GreyHead 27 May, 2011
Hi Stefan,

I'm not sure. I had expected the plug-in to handle the data re-loading (it's a long time since I used this). You might try setting the 'Try to Republish' option to 'Yes' on the child forms General tab. If that doesn't work then maybe the $posted array is needed.

Bob
stefanmarx 09 Jun, 2011
Hoooray :-)

So it works now. the secret was to use the following code, I dug out somewhere in the depth of a multipage thread in this marvelous forum:

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Back to previous step" name="back" type="button" onClick="window.location='http://your.site/index.php?option=com_chronocontact&chronoformname=mother_form&cfformstep=1'"/><input value="Move on" name="button_5" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>

So a normal submit button to move forward and a button of the type "button" with an onClick script to use the navigation links.

And of course the republish option has to be set to "Try to republish".

Anyway, if a user still uses his f*+#ing back button, the next time he presses the "Move on" button somewhere, it takes him to the next step after the page, where he started using his back-button. Be it so, I have written in big red unmistakable letters on the from, not to use the browser navigation, even if I don't like it at all.

Thanx Bob and all others in this forum, who encountered similar problems and whose solutions lead me onto the right path :-)

Cheers, Stefan
GreyHead 10 Jun, 2011
Hi Stefan,

Well done :-)

Bob
This topic is locked and no more replies can be posted.