We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12379
    • 460 Posts
    Using FormProcessor, I need to display some of the values submitted in the original "form_chunk" in the "confirmation_page_chunk"

    I’ve tried without luck using two snippets stuck at the top of the "form_chunk" and "confirmation_page_chunk":

    [!formSave!] at top of form_chunk
    <?php
    session_start();
    $_SESSION[’EventTitle’] = trim($_POST[’EventTitle’]);
    etc
    ?>

    [!formRetrieve!] at the top of confirmation_page_chunk
    <?php
    $modx->setPlaceholder(’EventTitle’, $_SESSION[’EventTitle’]);
    etc
    ?>

    The snippet call looks like this:

    [!FormProcessor? &form_chunk=`submitCalendar` &data_email_address=`[email protected]` &form_required=`Name,Description,Address,PhoneArea,Phone,Email,EventTitle,DateBegins,CompanyName,Address,CityStatePostcode` &data_email_subject=`Calendar Listing Request` &confirmation_page_chunk=`submitCalendarConfirmation`!]

    Not sure why it won’t work - can I use a snippet within a snippet?
      Mostly harmless.
      • 3749
      • 24,544 Posts
      Is it possible that the first form is writing the $_SESSION variables before their values exist?

      Have you tried just echoing the $_SESSION variables in a snippet in the second document to make sure they’re set correctly?

        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
        • 12379
        • 460 Posts
        Yes, you’re right. The second doc should have [!formSave!] at the beginning and then possibly the formRetrieve code within the same snippet, however the snippet doesn’t work in the chunk as I can see "[!formSession!]" (the new snippet) displaying at the top of the content area!

        If I simply put [+EventTitle+] in the confirmation_page_chunk somewhere no value displays.


        [!formSession!]
        <?php
        session_start();
        $_SESSION['EventTitle'] = trim($_POST['EventTitle']);
        $modx->setPlaceholder('EventTitle', $_SESSION['EventTitle']);
        ?>

          Mostly harmless.
          • 3749
          • 24,544 Posts
          Quote from: hotdiggity at Dec 23, 2008, 03:50 PM

          Yes, you’re right. The second doc should have [!formSave!] at the beginning and then possibly the formRetrieve code within the same snippet, however the snippet doesn’t work in the chunk as I can see "[!formSession!]" (the new snippet) displaying at the top of the content area!

          If I simply put [+EventTitle+] in the confirmation_page_chunk somewhere no value displays.


          [!formSession!]
          <?php
          session_start();
          $_SESSION['EventTitle'] = trim($_POST['EventTitle']);
          $modx->setPlaceholder('EventTitle', $_SESSION['EventTitle']);
          
          $output = $modx->getChunk('chunk_name');
          return ($output);
          ?>

          I think MODx is retrieving the chunk before the snippet executes. Can you use the code above in the second snippet instead? That should put things in the correct order.



            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
            • 12379
            • 460 Posts
            Sorry, don’t quite understand. What’s does "chunk_name" become?

            I’ve change the name of the second snippet to [!formSession!] with your code and put that at the top of FormProcessor’s "confirmation_page_chunk" but it’s still not executing it:

            [!FormProcessor? &form_chunk=`submitCalendar` &data_email_address=`[email protected]` &form_required=`Name,Description,Address,PhoneArea,Phone,Email,EventTitle,DateBegins,CompanyName,Address,CityStatePostcode` &data_email_subject=`Calendar Listing Request` &confirmation_page_chunk=`submitCalendarConfirmation`!]


            submitCalendarConfirmation:
            [!formSession!]
            <p class="introtext">
            Thanks for submitting your event listing for [+EventTitle+].
            </p>
            <p>Please proceed to PayPal to make your payment. Event listings will only be posted once payment is confirmed.</p>
            <br />
            <form method="post" action="https://www.paypal.com/cgi-bin/webscr">
            <fieldset>
            <legend>Payment</legend>
            <p>All payment transactions are carried out securely via PayPal using Mastercard and Visa.</p>
            <input type="hidden" name="cmd" value="_cart">
            <input type="hidden" name="add" value="1">
            <input type="hidden" name="business" value="[email protected]">
            <input type="hidden" name="item_name" value="[+EventTitle+] - Event Listing">
            <input type="hidden" name="item_number" value="LIST">
            <input type="hidden" name="amount" value="79.00">
            <input type="hidden" name="currency_code" value="AUD">
            <input type="hidden" name="return" value="http://www.mydomain.com.au/thank-you">
            <input type="hidden" name="undefined_quantity" value="1">
            <button type="submit" name="submit" class="cart" value="Submit">Proceed to payment</button>
            </fieldset>
            </form>


            formSession:
            <?php
            session_start();
            $_SESSION['EventTitle'] = trim($_POST['EventTitle']);
            $modx->setPlaceholder('EventTitle', $_SESSION['EventTitle']);
            
            $output = $modx->getChunk('chunk_name');
            return ($output);
            ?>


              Mostly harmless.
              • 3749
              • 24,544 Posts
              chunk_name should be replaced by the name of the chunk you create. That chunk would hold this:

              <p class="introtext">
              Thanks for submitting your event listing for [+EventTitle+].
              </p>
              <p>Please proceed to PayPal to make your payment. Event listings will only be posted once payment is confirmed.</p>
              <br />
              <form method="post" action="https://www.paypal.com/cgi-bin/webscr">
              <fieldset>
              <legend>Payment</legend>
              <p>All payment transactions are carried out securely via PayPal using Mastercard and Visa.</p>
              <input type="hidden" name="cmd" value="_cart">
              <input type="hidden" name="add" value="1">
              <input type="hidden" name="business" value="[email protected]">
              <input type="hidden" name="item_name" value="[+EventTitle+] - Event Listing">
              <input type="hidden" name="item_number" value="LIST">
              <input type="hidden" name="amount" value="79.00">
              <input type="hidden" name="currency_code" value="AUD">
              <input type="hidden" name="return" value="http://www.mydomain.com.au/thank-you">
              <input type="hidden" name="undefined_quantity" value="1">
              <button type="submit" name="submit" class="cart" value="Submit">Proceed to payment</button>
              </fieldset>
              </form>


              Which you’d remove from the document (since it will all be returned from the snippet -- hopefully, with the placeholders properly filled).

              I hope I understand what you’re trying to do. I’ve never used FormProcessor so I’m guessing here, and there may be an easier way to do what you want.




                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
                • 12379
                • 460 Posts
                i think the problem is the snippet calls a chunk which has a snippet in it. ie FormProcessor snippet calls the confirmation page chunk`submitCalendarConfirmation` which in turn has the [!formSession!] in it plus the rest of the chunk code.


                [!FormProcessor? &form_chunk=`submitCalendar` &data_email_address=`[email protected]` &form_required=`Name,Description,Address,PhoneArea,Phone,Email,EventTitle,DateBegins,CompanyName,Address,CityStatePostcode` &data_email_subject=`Calendar Listing Request` &confirmation_page_chunk=`submitCalendarConfirmation`!]
                  Mostly harmless.
                  • 3749
                  • 24,544 Posts
                  Ok, I’ve looked at the FormProcessor snippet. If I understand you correctly, you just have some user input from the original form that you’d like to display on the confirmation page. If that’s the case, you shouldn’t need $_SESSION variables at all or any extra snippets.

                  FP creates a form that posts to itself. The first time it’s called, it just displays the form with the render_form() function, which simply displays the chunk you specify as holding the form. Presumably, your input fields are in that form.

                  On the second pass (post-back), it optionally

                  Creates the DB if it doesn’t exist (check_database() )
                  Writes to the DB (write_database() )
                  Emails the results (email_data() )
                  Displays the confirmation page (render_confirmation() )

                  Since the data you want to display is present in the $_POST array, all you should need to do is to set your placeholders at the very beginning of the render_confirmation() function. Remember that placholders are case-sensitive so they have to match the placeholders in your confirmation chunk.

                  IOW, replace this part of the render_confirmation function:

                  if($confirmation) {
                  
                    // Return the confirmation chunk
                    $html = '{{'.$confirmation.'}}';
                  
                   } else {


                  with this:

                  if($confirmation) {
                  
                     // set my placeholders
                     $modx->setPlaceholder('EventTitle', trim($_POST['EventTitle'] ));
                  
                  
                    // Return the confirmation chunk
                    $html = '{{'.$confirmation.'}}';
                  
                   } else {


                  If you need the placeholders set in the email also, you’ll need to do the same thing in the email_data() function.

                  That should do it. Hope this helps. smiley
                    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
                    • 12379
                    • 460 Posts
                    The email processed ok, but the return screen was blank...
                      Mostly harmless.
                      • 3749
                      • 24,544 Posts
                      A blank screen usually means an HTML or PHP syntax error on the page. Do you see anything with "view source" on that page?
                        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