2

Have a curly one for those who know more then me.

Picture this: A site has a form to submit a warranty registration. Capture: Name, email, street address, model name and serial number.

All good,this first part is a no-brainer. Fill out the stuff, submit, fire off thankyou emails to client and company then return to a generic "thanks" page.

What the client seeks though, is rarely, straight forward but must be achievable.

Let's alter the params for a moment. Let's say the user has bought several machines and they want to register each of them. Initial thought is to create say 6 duplicate fields in Freeform (6 X machine name, 6 X serial name) and display them – but a tad redundant to show all 6 if they bought 1 or what happens if they bought 12 ? Plus, too many fields to manage in the backend.

It was suggested that the user fills out all the "personal" details and we only display 1 set of machine/serial fields.

The user then has the choice of 2 buttons, either #1 "submit, I only bought one" or #2 "submit this one and then I'll add another"

If they choose option #2, how could you bring back all the previous "personal" details pre-populated and present a new, empty set of fields for machine/serial#?

Long story short, user submits one entry for one machine (one record per machine, technically speaking), if they choose to submit another, their "personal" details are pre-populated ready for another product registration - how ?

As I write, I see stash in the equation but not sure how to set the variables until they're posted… a good Friday question :)

1

Freeform lets you use the %%entry_id%% placeholder in the return parameter. You could use this to load the entry that was just submitted (with the freeform:entries tag), then populate your personal info with at entry (but exclude the info for the products being registered).

What I'd do is include a checkbox in your initial form for "I have more products to register". Then, on your resulting page, if that box was checked for the first entry, show a new form with the info pre-populated. If it was not, then just show the "thank you" message.

Assuming this:

  • you have the aforementioned checkbox and it's named registration_multiple
  • your initial Freeform Form tag has return="warranty/submitted/%%entry_id%%

... here is some quick pseudo-code for your warranty/submitted template:

{exp:freeform:entries entry_id="{segment_3}" limit="1"}
{if registration_multiple == 'y'}
    {exp:freeform:form form_id="1" `return="warranty/submitted/%%entry_id%%"}
        <input type="text" name="name" value="{name}" />
        <input type="email" name="email" value="{email}" />
        ... etc ..
    {/exp:freeform:form}
{if:else}
    <p>Thank you for registering your product!</p>
{/if}
{/exp:freeform_entries}
1
  • Thx for that, I'll probably use this method with a cookie or session to make sure only the person submitting the data can add to it. – stuartmcd69 Feb 3 '13 at 1:23
0

You could switch from using Freeform to using Safecracker and storing these in entries.

You can use a Matrix field for each product they're registering, and give them a + button to add new rows to their Matrix fields using JavaScript.

We did this with an event registration site, where there was a primary registrant and they would add multiple attendees to their registration within 1 form.

As described in this answer, you can then trigger the notification emails when the Safecracker form is submitted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.