On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Let me explain with an simple example: I have 2 forms on 2 different pages, 1 form per page. Form1 has a field called name1 and form2 a field called name2.

    I'm using a formit to a resultpage (id=12) where I want to show both name1 and name2. I use the store-function of FormIt to keep the data in session.

    [[!FormItRetriever? &storeLocation=`session`]]
    
    [[!FormIt? 
    &submitVar=`send`
    &hooks=`redirect`
    &redirectTo=`12`
    &store=`1`
    &storeLocation=`session`
    &storeTime=`900`
    ]]
    
    on the resultpage I call [[+fi.name1]] and [[+fi.name2]]
    


    The problem is that only the last filled in name is showed on the resultpage. So if I last fill in name2 then name1 is blank on the resultpage and name2 is filled in and vice versa.

    Am I getting crazy or why is this not working?

    This question has been answered by sitsol. See the first response.

    • Is the "name" attribute different? That's what ends up in the $_POST.

      As for the general problem, I think you could put the fields of the first form in the second form as hidden fields and set their values with a preHook in the second page. That way, all fields will end up in the $_POST array when the second page is submitted.

      Assuming that the first page is posting to the second page, I would do it with a custom snippet at the top of the second page. Something like this:

      $firstFormFields = array(
           "name1",
           "someotherfield",
           "yetanotherfield",
      }
      
      foreach($firstFormFields as $field) {
          if (array_key_exists($_POST, $field)) {
             $modx->setPlaceholder($field, $_POST[$field]);
          }
      
      }
      
      return '';
        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
      • Thx BobRay.

        The forms are not following eachother. Just think of it as some kind of very simple shoppingcart.

        The customer fills in one form, goes to some other pages and then fills in second form (or third, or fourth, ...) en everything should come together if they go to the resultpage.

        Even better should be if name1, name2, name3, etc... could have the same name and put together in an array. In that way it's more dynamic.

        Hope you understand what I mean.
        • discuss.answer
          I have solved it by using simplecart js (http://simplecartjs.org/).
          • I'm glad you got it sorted. 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