Multiple form submit buttons with different actions / redirects

I have a subscription form here https://step2you.divhunt.website/inscription which objective is to collect subscription of schools.
Each teacher can register a school and one class and submit, but in some cases, the teacher might need to enroll several classes.
In this case, in order to make subscription process easy, I would like to have 2 buttons:

  1. simple submission: for direct submission of one class
  2. submit and add new: to submit class subscription and then redirect to same form, this time pre-filled with email and school information so they only need to provide class information. The teacher could then loop as many times as they have classes to enroll without having to fill in again the same school information, and at the last class, they would perform the simple submit (first button).

A. (How) can I achieve this?
B. Can I use the code redirect solution for button 2 only?

C. Can I use form prefill in the button 2 redirect url? (how do I catch field values to put them in the url parameters?)

Hi @Fanny
you can filter the submissions from different forms by a simple if statement in your custom js code, checking for the form id.

Like here:

if (data.form.id === PASTE_YOUR_FORM_ID_HERE) {
YOUR OTHER CODE
}

Best

J. from Caen (temporarily)

Maybe I was not clear in my post: there is only one form.

I want to be able to loop into this form after submission as many times as needed for the subscriber, but have information prefilled in subsequent loops (e.g. first/ last name and email will always be the same, so I don’t want them to have to fill in again)

Oh yes, now… Sorry.
Two solutions come to mind:

  1. You could activate the autofill browser property in the form controls (Divhunt frontend). Not as effective and still requires action on user side, but quick and easy.

  2. Write custom code, that puts the desired values into global variables after the first form submit. And simultaneously use this vars as prefill in the form fields. This would also require to set the vars with default values.

1=> already configured, but indeed it still requires end user action

2=> I am very interested to get more info on how to do that !
Question: how will it work if different people submit a form almost simultaneously?

For now, I have configured the form fields to be prefilled using url parameters, and it works well.
I was actually thinking of this second button to redirect on such url.
Or maybe I should use only one button doing this, and user would simply exit the tab in case no more subscriptions are needed. Not sure what is the most efficient way to do that.

https://step2you.divhunt.website/inscription?prenom=Fan&nom=Test&email=test%40gmail.com&zip=1000&etablissement=ABC&ville=Bruxelles

Oh yes, I forgot about different users using the form simultaneously… I have no idea, have to admit I’m a noob trying to figure things out here…

lol me too :sweat_smile:
But I am sure that helping each other will enable us to achieve what we want :muscle:

2 Likes

I forgot to come back and post the solution found.

Here is how I achieved to do what I needed:

  1. on the form, I use one submit button Step2you | Inscription Cap'ten
  2. after submission, I have configured a section which is visible on successful submission. In this section, I have included 4 buttons (because there are 4 possible programs to subscribe from).
  3. For each button, I have configured a link towards the specific program page, and added parameters in the url in order to prefill the next form with already entered data . This is what each each link looks like:
    /inscription-cap-ten?prenom=${query->get('prenom','')}&nom=${query->get('nom','')}&email=${query->get('email','')}&tel=${query->get('tel','')}&zip=${query->get('zip','')}&ville=${query->get('ville','')}&etablissement=${query->get('etablissement','')}

Prerequisite: the user should land on the form using a url with these parameters filled in in the url. In this particular case, they are invited to subscribe via email containing personalized url.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.