<![CDATA[ eForm example: How to split a form into multiple "pages" - My Forums]]> https://forums.modx.com/thread/?thread=46652 <![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270630 Here it is. It’s an extract of quite a big solution so I’m not absolutely sure if it is complete. But I will sure give a hand if somebody has questions.
if(!function_exists("beforeMailSentFunction")){
	//store results in session and advance form
	function beforeMailSentFunction(&$fields){
		global $modx;
		
		if (!is_array($_SESSION['mySession'])) $_SESSION['mySession'] = array();
			
//save values in session
		$_SESSION['mySession'] = array_merge ($_SESSION['mySession'],$fields);
						
		$step = isset($fields['formStep'])?$fields['formStep']:1;
		
//	don't use $fields['backbutton'] because its set anyway by eForm
		$backbutton = $_POST['backbutton']? -1:1;
		$step = max($step + $backbutton,1); //prepare next step
		$_SESSION['mySession']['formStep'] = $step; //prepare next step
		if ($step > 2){ //last form	

			// clear formstep 
			unset($_SESSION['mySession']['formStep']);   
							
			return true; //
		}

		// except for the last step we clear the $_POST array
		// and bypass eform and re-open the page with the next form
		//unset($_POST); - doesn't work in php 4.3.xx 
		$_POST = array();
		$modx->sendForward($modx->documentIdentifier);
		return false; //
	}
}

I hope this helps.
Good luck and regards
manu]]>
manu37 Apr 27, 2011, 11:13 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270630
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270629 Heres is my code to provide this:
if(!function_exists("elipsTriaOnbeforeMergeFunction")){
	//Display different form depending on session
	function elipsTriaOnbeforeMergeFunction( &$fields ){
		global $modx,$formats;
		foreach ($formats as $key=>$val) 
			if (empty($_POST[$key]) ) 	//doesn't work with $fields[$key]
				if (isset($_SESSION['mySession'][$key])) 
					switch ($formats[$key][2]) {	//data type
					case 'integer': case 'float':	//strip formatting
						$fields[$key] = (float) str_replace("'",'',$_SESSION['mySession'][$key]);
						break;
					default:
						$fields[$key] = $_SESSION['mySession'][$key];
					}
				else
//set standard values
					switch ($key){
					case 'begindate': 
						$fields[$key] = strftime("%d.%m.%Y",time());
						break;
					}
	}
}

If someone has a straighter solution, let me know.
I also have a solution for a real "back" button, but that’s another story.
regards manu

PS: eform works on 1.0.4 without problems.
]]>
manu37 Nov 17, 2010, 09:50 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270629
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270628

Because the basic exemple isn’t working for me.
It gives a blank screen when i click on the submit button

Need to get this working for my next project sad

Somebody can help me?...]]>
visvoer Dec 26, 2009, 07:32 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270628
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270627
I want to have a subscribe link on my home page with just an email field and pass this through to subsequent real pages..]]>
nolner Dec 20, 2009, 11:32 PM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270627
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270626
	<?php	// Loop through each column, and insert it if present in the form
		foreach ( $tblColumns as $tblCol ){
			if (isset ( $_SESSION ['krediet'] [$tblCol] )){
				$dbTable [$tblCol] = $_SESSION ['krediet'] [$tblCol];
			    }
                }
                $dbTable [datum] = time ();
		// Run the db insert query
		$dbQuery = $modx->db->insert ( $dbTable, 'krediet_aanvragen' );
            
                // set alle velden weer in $fields zodat we een report kunnen maken met alle velden.
               $fields = $dbTable;
               $fields['test'] = "test123";
               $fields['formid'] = "watleuk";
return true;


the fields are in the db BUT the fields I changed and added in this case:
$fields = $dbTable;
$fields[’test’] = "test123";
$fields[’formid’] = "newid"
are not in my report
formid has the original formid string and not the "newid" string i put in here.
looks like $fields is not renewed in this case.

do I miss something?

]]>
Dimmy Oct 09, 2009, 03:43 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270626
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270625 tariel Sep 21, 2009, 06:40 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270625 <![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270624
<a href="javascript: window.history.go(-1)">Edit</a> 

and change the -1 to wheat ever you like?

hope this helps!!]]>
wiggy Sep 21, 2009, 02:00 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=8#dis-post-270624
<![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270623 tariel Sep 20, 2009, 01:28 PM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270623 <![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270622 I have tried to use one and it shows on the page correctly but when you move onto the next part of the form it throws up "invalided value?"]]> wiggy Sep 18, 2009, 03:05 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270622 <![CDATA[Re: eForm example: How to split a form into multiple &quot;pages&quot;]]> https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270621 opengeek Aug 10, 2009, 10:41 AM https://forums.modx.com/thread/46652/eform-example-how-to-split-a-form-into-multiple-pages?page=7#dis-post-270621