We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15051
    • 7 Posts
    Quote from: allanb at Sep 21, 2010, 09:37 PM

    Maybe you could post you solution so I and others can learn.

    Well, i’ve just had five minutes look at this and the solution (using no.2 saving to sessions) was faster to implement than writing my previous post.

    1. Add a formit hook with the following code:

    <?php
    $_SESSION['last_form'] = $scriptProperties['fields'];
    
    return true;
    ?>
    


    This saves the form fields into the session. You can change the session key or even make it dynamic.

    2. On the confirmation page where the user is redirected, simply make a call to another snippet that has the following code:

    <?php
    if (isset($_SESSION['last_form']))
    {
       $modx->setPlaceholders($_SESSION['last_form'], 'fi.');
    }
    return '';
    ?>
    


    Again, note the use of the "last_form" key. You can use whatever you want to avoid clashes in the session scope or make it dynamic using a snippet call parameter.

    Once this snippet has run, placeholders with names matching the form fields will be available (also note the ’fi’ prefix, again you can choose what you want)

    So, on your confirmation page you can just call the snippet as follows:

    [[!SessionFormToPlaceholders]]
    
    You submitted:<br>
    Name: [[+fi.name]]
    


    There are flaws to this approach and it’s not as robust as it could be but it’s good enough for me for the moment.

    I’ve also updated the other thread about saving to the database. It’s easy to combine the two if needed.
      • 1169
      • 312 Posts
      Thanks for taking the trouble to reply.

      It has helped me to understand Sessions a bit better.

      NOW IF ONLY WE HAD SOME WAY OF SAVING ALL THESE WORKING SOLUTIONS AND A WAY TO CATEGORIZE THEM sad

      There are lots of lost good solutions buried in these forums.
        DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
        • 15051
        • 7 Posts
        Quote from: allanb at Sep 22, 2010, 10:02 AM

        NOW IF ONLY WE HAD SOME WAY OF SAVING ALL THESE WORKING SOLUTIONS AND A WAY TO CATEGORIZE THEM sad

        I’ll happily contribute this example and a few others to the addon docs for formit here:

        http://rtfm.modx.com/display/ADDON/FormIt#FormIt-AccessingtheFormitfieldsinthesnippet

        I’m just deciding whether I want to agree to the terms of the MODx Contributor Licence Agreement: http://modxcms.com/develop/contribute/cla.html

        If I go ahead with it hopefully the powers that be will give me a Confluence login.

        I’m also investigating how I can contribute directly to the formit addon so that some of the features described on the roadmap will happen sooner rather than later...
        • Would love to have you contributing junkend ... thanks for what you’ve done so far. The CLA protects you and any other users of the software, and is the same form as what the Apache Foundation requires for all their contributors.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 28215
            • 4,149 Posts
            Sending a CLA will get you access to the docs quickly. Patches to FormIt code can be sent as Pull Requests on GitHub, without any special access needed. They will then be approved and reviewed.

            As for fields being passed to a thank you page - that will happen soon. It’s on my roadmap and on my plan for this week.
              shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com