We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Hi

    I want a simple form on my homepage which collects basic data - and after submitting takes the user to part 2 of the form which requires more detail.
    If they don't complete part 2, at least we have basic info from part one stored and emailed.

    What's the best method in modx for something like this?

    Thanks
    Andy
      • 50124
      • 11 Posts
      Are you submitting the data on another page then the page that contains the second form ? if so you could store the information in a session
        • 51020
        • 670 Posts
        Yes it fouls be a second page. But I want to collect the data in between submissions if that makes sense?
          • 17301
          • 932 Posts
          How are you hoping to attribute data to the user on the second form? Will some values be repeated on the second form such as name or email ?

          You could perhaps create it as two seperate formit calls and after the first one is submitted redirect to the second form and use formit retriever to retrieve some details in a hidden field, such as email.

          The problem though will be when you want to merge the data together. It may be a manual process of matching ip address or email submissions together.

          If the users will be registered and logged in on the site then it could be a different scenario potentially.
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • 3749
            • 24,544 Posts
            One method would be to use a custom snippet to process the form submission on the first page. That snippet could save the form data in a $_SESSION variable as Jasper suggests, send an email, and/or perform other tasks, then forward the user to the second form's page with $modx->sendRedirect($url).

            On that second page, a custom snippet at the top could grab the $_SESSION variable, use it to set placeholders, and clear the $_SESSION variable.

            As LK said, merging the data from the two forms could be tricky.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 51020
              • 670 Posts
              I was going to repeat the fields in the second form but autocomplete and hide them using in the URL to the second form. E.g.
              Form.html&[email protected]

                • 3749
                • 24,544 Posts
                That should work if the first form posts to the second one, though you're going to need some code on the second form to get the values and fill the fields.

                Using the $_SESSION variable would be more secure and would accomplish the same thing. Setting them as placeholders would do the autocomplete part.

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 51020
                  • 670 Posts
                  Quote from: BobRay at Jul 24, 2017, 03:05 AM
                  That should work if the first form posts to the second one, though you're going to need some code on the second form to get the values and fill the fields.

                  Using the $_SESSION variable would be more secure and would accomplish the same thing. Setting them as placeholders would do the autocomplete part.


                  OK thanks for the steer - I'll have a play and report back if I find a good solution