<![CDATA[ How to collect different forms to one result? - My Forums]]> https://forums.modx.com/thread/?thread=103925 <![CDATA[How to collect different forms to one result?]]> https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558928
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?]]>
sitsol Jun 06, 2018, 04:50 AM https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558928
<![CDATA[Re: How to collect different forms to one result?]]> https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558958 ]]> BobRay Jun 07, 2018, 06:47 AM https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558958 <![CDATA[Re: How to collect different forms to one result? (Best Answer)]]> https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558952 http://simplecartjs.org/).]]> sitsol Jun 07, 2018, 03:06 AM https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558952 <![CDATA[Re: How to collect different forms to one result?]]> https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558940
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.]]>
sitsol Jun 06, 2018, 12:30 PM https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558940
<![CDATA[Re: How to collect different forms to one result?]]> https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558934
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 '';
]]>
BobRay Jun 06, 2018, 06:26 AM https://forums.modx.com/thread/103925/how-to-collect-different-forms-to-one-result#dis-post-558934