We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8807
    • 9 Posts
    I’m trying to copy your multipage eform example. Running modx .0.9.6, eform 1.4.4

    I obviously can’t follow instructions properly, because it doesn’t quite work.

    I can see page one of the form, I can fill it out and click next, but I get a blank page and apache error log says "PHP Fatal error: Call to undefined function beforeParseFunction() in /var/www/html/modx/assets/snippets/eform/eform.inc.php on line 138"

    I’ve added chunks, formOne, formTwo, formThree and formReport
    And added snippet, multiFormFunctions

    The Document looks like:
    [[multiFormFunctions]]
    [!eForm?&noemail=`true`&formid=`contact`&tpl=`formOne`&eFormOnBeforeFormParse=`beforeParseFunction`&eformOnBeforeMailSent=`beforeMailSentFunction`&thankyou=`formReport`!]
      • 24719
      • 194 Posts
      Quote from: goddang at Mar 15, 2007, 08:49 AM

      Ok, I seem to have found a solution to my problem. If I change the "$modx->sendForward($modx->documentIdentifier);" to "$modx->sendRedirect($modx->makeUrl($modx->documentIdentifier));"
      It works.

      Just thought I share my discoveries.

      /dang


      all snippets on the page are executed properly with this change, but then ff and ie7 (not sure about other browsers) don’t add the form steps to the back button, so the user can’t go back through the steps. has anyone else noticed this and found a solution? without this change, other snippets on later steps don’t execute, but the back button works properly...
        • 32795
        • 2 Posts
        Quote from: emdeex at Sep 06, 2007, 01:28 AM

        I’m trying to copy your multipage eform example. Running modx .0.9.6, eform 1.4.4

        I obviously can’t follow instructions properly, because it doesn’t quite work.

        I can see page one of the form, I can fill it out and click next, but I get a blank page and apache error log says "PHP Fatal error: Call to undefined function beforeParseFunction() in /var/www/html/modx/assets/snippets/eform/eform.inc.php on line 138"

        I’ve added chunks, formOne, formTwo, formThree and formReport
        And added snippet, multiFormFunctions

        The Document looks like:
        [[multiFormFunctions]]
        [!eForm?&noemail=`true`&formid=`contact`&tpl=`formOne`&eFormOnBeforeFormParse=`beforeParseFunction`&eformOnBeforeMailSent=`beforeMailSentFunction`&thankyou=`formReport`!]

        I am having this issue too, with the php fatal error. I’ve tried replacing the sendForward() function with sendRedirect() in the beforeMailSentFunction(), but this doesn’t help, and I don’t see how it could, being that the error is with eForm’s eFormOnBeforeFormParse callback.

        Has this been resolved?
          • 3177
          • 137 Posts
          Yes, Here the same error:
          Fatal error: Call to undefined function beforeParseFunction() in [fullpath]/assets/snippets/eform/eform.inc.php on line 138
          Since I don’t see the message in the previous replies, it might have something to do
          with the newer versions of eForm and/or MODX?

          Hope somebody can help us out on this.

          Thank,

          BertCatsburg
            • 3177
            • 137 Posts
            Oops,
            Clearing the Cache solved the problem !!!
            Sorry for not looking further away than my nose is long (Dutch expression)
              • 3177
              • 137 Posts
              Again, too fast.
              I solved the problem by putting the MultiForms snippet in a copy of the eForm snippet itself. That was what solved it.
                • 32795
                • 2 Posts
                Okay, I got the multiform working, thanks bert...

                The thing is, what I really want is for the form2 to go to a full separate page, where the form will be. So instead of having just the little Name/Email form "refresh" to show the next form in the series, I want all forms after the first to be their own *page*. Make since?

                This may be a different topic all together, but I really don’t know enough about modx to know how to do this. It’s easy with just straight php, but like I said, it’s all inside the modx api, which I have yet to familiarize myself with.
                • Would be easy with eForm. Use one of the events to load the stuff into the SESSION. Have it configured to go to another page on submission. On the other page have another eform call, use the onBeforeFormMerge event to load the stuff from the SESSION into the form fields on that page, rinse and repeat as needed.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 32424
                    • 19 Posts
                    Heya - I am having problems with a two page form I set up using this example. Upon submitting the second page, I am returned to the first page of the form, all fields are blank, and the validation message is saying that they are all required (which is true).

                    My multiFormFunctions snippet looks like this (edit to use only 2 form pages):
                    <?php
                    if(!function_exists("beforeParseFunction")){
                      //Display different form depending on session
                      function beforeParseFunction( &$fields, &$templates ){
                        global $_lang;
                        //which form should we load?
                        // $step is set in beforeMailSentFunction or comes from the hidden field
                        // we need to do both so that when we step back (eg. the back button of the browser)
                        // we still get the proper form
                        if(isset($_SESSION['formStep']))
                          $step = $_SESSION['formStep'];
                        else
                          $step = isset($_POST['formStep'])?$_POST['formStep']:1;
                        //Kill the session var as otherwise we can't go back to a previous step at all
                        unset($_SESSION['formStep']);
                        $tpl = $templates['tpl'];
                        // Replace form template when needed
                        switch($step){
                        case 1: //form not yet posted so use tpl as set in snippet call
                          return true;
                        case 2:
                          $replaceTpl = "twopage_app_form2_page2";
                          break;
                        //case 3:
                         // $replaceTpl = "multiForm3";
                         // break;
                        default: //should never get here
                          return false;
                        }
                        if($step>1)
                          if( $tmp=efLoadTemplate($replaceTpl) ) $tpl=$tmp; else $tpl = $_lang['ef_no_doc'] . " '$replaceTpl'";
                    
                        //restore template in array
                        $templates['tpl']=$tpl;
                        return true;
                      }
                    }
                    
                    if(!function_exists("beforeMailSentFunction")){
                      //store results in session and advance form
                      function beforeMailSentFunction(&$fields){
                        global $modx;
                        $step = isset($fields['formStep'])?$fields['formStep']:1;
                        switch($step){
                        case 1: //save values in session
                          $_SESSION['FirstName']= $fields['FirstName'];
                          $_SESSION['LastName']= $fields['LastName'];
                     $_SESSION['Email']= $fields['Email'];
                     $_SESSION['ZipCode']= $fields['ZipCode'];
                     $_SESSION['Plans']= $fields['Plans'];
                     $_SESSION['Gender']= $fields['Gender'];
                     $_SESSION['DOB']= $fields['DOB'];
                     $_SESSION['Tobacco']= $fields['Tobacco'];
                     $_SESSION['Height']= $fields['Height'];
                     $_SESSION['Weight']= $fields['Weight'];
                     $_SESSION['formStep'] = 2; //prepare next step
                          break;
                    
                        case 2: //save values in session
                          $_SESSION['spousename']= $fields['spousename'];
                          $_SESSION['SpouseGender']= $fields['SpouseGender'];
                    $_SESSION['SpouseDOB']= $fields['SpouseDOB'];
                    $_SESSION['SpouseTobacco']= $fields['SpouseTobacco'];
                    $_SESSION['SpouseHeight']= $fields['SpouseHeight'];
                    $_SESSION['SpouseWeight']= $fields['SpouseWeight'];
                     $_SESSION['formused']= $fields['formused'];
                     $_SESSION['communications']= $fields['communications'];
                    $_SESSION['dep1name']= $fields['dep1name'];
                    $_SESSION['D1Gender']= $fields['D1Gender'];
                    $_SESSION['D1DOB']= $fields['D1DOB'];
                    $_SESSION['dep2name']= $fields['dep2name'];
                    $_SESSION['D2Gender']= $fields['D2Gender'];
                    $_SESSION['D2DOB']= $fields['D2DOB'];
                    $_SESSION['dep3name']= $fields['dep3name'];
                    $_SESSION['D3Gender']= $fields['D3Gender'];
                    $_SESSION['D3DOB']= $fields['D3DOB'];
                    $_SESSION['dep4name']= $fields['dep4name'];
                    $_SESSION['D4Gender']= $fields['D4Gender'];
                    $_SESSION['D4DOB']= $fields['D4DOB'];
                    $_SESSION['dep5name']= $fields['dep5name'];
                    $_SESSION['D5Gender']= $fields['D5Gender'];
                    $_SESSION['D5DOB']= $fields['D5DOB'];
                      $_SESSION['FirstName']= $fields['FirstName'];
                          $_SESSION['LastName']= $fields['LastName'];
                     $_SESSION['Email']= $fields['Email'];
                     $_SESSION['ZipCode']= $fields['ZipCode'];
                     $_SESSION['Plans']= $fields['Plans'];
                     $_SESSION['Gender']= $fields['Gender'];
                     $_SESSION['DOB']= $fields['DOB'];
                     $_SESSION['Tobacco']= $fields['Tobacco'];
                     $_SESSION['Height']= $fields['Height'];
                     $_SESSION['Weight']= $fields['Weight'];
                    
                    return true; //return now and let eForm do it's thing
                    		default: //should never get here
                    			return false;
                    		}
                    
                       // 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; //
                      }
                    }
                    //return from snippet
                    return "";
                    ?>


                    My first form’s chunk looks like this:
                    <h1 class="form_head">Request an Application</h1>
                    <p class="centered">Fields with an <strong>*</strong> must be completed</p>
                    [[validation_open]][+validationmessage+][[validation_close]]
                    <form action="[~[*id*]~]" method="post" id="twopage_app_form2" class="gen_form">
                    
                    
                        <input type="hidden" name="formStep" value="1" />
                    <input type="hidden" name="formid" value="twopage_app_form2" />
                        <fieldset>
                                 <div class="left">
                    			<p>
                    	            <label><strong>*</strong> First Name</label>
                    	            <input class="field" type="text" name="FirstName" maxlength="60" eform="First Name:string:1:Your First Name is required" />
                    	        </p>
                    	        <p>
                    	            <label><strong>*</strong> Last Name</label>       
                    	            <input class="field" type="text" name="LastName" maxlength="60" eform="Last Name:string:1:Your Last Name is required" />
                    	        </p>
                    			<p>
                    	            <label><strong>*</strong> Email</label>
                    				<input class="field" type="text" name="Email" maxlength="60" eform="Email Address:email:1" />
                    	        </p>
                    	        
                    			<p>
                    	            <label><strong>*</strong> Zip Code</label>
                    				<input class="field" type="text" name="ZipCode" size="40" maxlength="40" eform="Zip Code::1:Your Zip Code is required" />
                    	        </p>
                    		</div>
                    		<div class="rite">
                    			<p>
                    				Product(s) to Quote
                    			</p>
                    			<p>
                    	        		[[check_boxes]]
                    	        </p>
                    			
                    			
                    			<p>
                    	            <label class="mini"><strong>*</strong> Gender</label>       
                    				<select class="mini" name="Gender" eform="Gender::1:You must select your Gender">
                    	                <option value="">Select</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    	        </p>
                    			<p>
                    	            <label class="mini"><strong>*</strong> DOB</label>       
                    				<input class="mini" type="text" name="DOB" maxlength="10" value="MM/DD/YYYY" onClick="this.value = '';" eform="Date of Birth (DOB):string:1:Your Date of Birth is required" />
                    	        </p>
                    
                    <p>
                    	            <label class="mini"><strong>*</strong> Tobacco use in last 12 months?r</label>       
                    				<select class="mini" name="Tobacco" eform="Tobacco::1:You must select your Tobacco Use">
                    	                <option value="">Select</option>
                    					<option value="Y">Yes</option>
                    					<option value="N">No</option>
                    	            </select>
                    	        </p>
                    
                    <p>
                    	            <label><strong>*</strong> Height</label>
                    				<input class="field" type="text" name="Height" size="40" maxlength="40" eform="Height::1:Your Zip Code is required" />
                    	        </p>
                    
                    <p>
                    	            <label><strong>*</strong> Weight</label>
                    				<input class="field" type="text" name="Weight" size="40" maxlength="40" eform="Weight::1:Your Zip Code is required" />
                    	        </p>
                    
                    
                    
                    
                    
                    
                    		</div>
                        </fieldset>
                    
                            
                    			
                    
                    
                    	<p>
                    		<label></label>       
                            <input type="image" src="[(base_url)]assets/images/layout/btn_continue.gif" name="frmGo" value="Continue" class="no_box" />
                        </p>
                    </form>


                    And my second form’s chunk looks like this:
                    <h1 class="form_head">Step 2</h1>
                    <p class="error">[+validationmessage+]</p> 
                    <form action="[~[*id*]~]" method="post" id="twopage_app_form2" class="gen_form">
                    
                    <input type="hidden" name="formused" value="Two Page Short Form" />
                    <input type="hidden" name="communications" value="Form Submitted" />
                    <input type="hidden" name="formid" value="twopage_app_form2" />
                        <input type="hidden" name="formStep" value="1" eform="formStep:integer:1:Value out of step:#RANGE 1-2" />
                    
                        <fieldset>
                    <p>
                                <label>Spouse Name</label>
                    				<input class="field" type="text" name="spousename" maxlength="60" />
                    				<select class="mini" name="SpouseGender">
                    	                <option value="">Gender</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="SpouseDOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    
                    <p>
                    	            <label style="width:200px;">Tobacco use in last 12 months?</label>       
                    				<select name="SpouseTobacco">
                    	                <option value="">Select</option>
                    					<option value="Y">Yes</option>
                    					<option value="N">No</option>
                    	            </select>
                    	        </p>
                    
                    <p>
                    	            <label>Spouse's Height</label>
                    				<input class="field" type="text" name="SpouseHeight" size="40" maxlength="40" />
                    	        </p>
                    
                    <p>
                    	            <label>Spouse's Weight</label>
                    				<input class="field" type="text" name="SpouseWeight" size="40" maxlength="40" />
                    	        </p>
                    
                    
                    			<p>
                    	            <label>Dependant Name</label>
                    				<input class="field" type="text" name="dep1name" maxlength="60" />
                    				<select class="mini" name="D1Gender">
                    	                <option value="">Sex</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="D1DOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    			<p>
                    	            <label>Dependant Name</label>
                    				<input class="field" type="text" name="dep2name" maxlength="60" />
                    				<select class="mini" name="D2Gender">
                    	                <option value="">Sex</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="D2DOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    			<p>
                    	            <label>Dependant Name</label>
                    				<input class="field" type="text" name="dep3name" maxlength="60" />
                    				<select class="mini" name="D3Gender">
                    	                <option value="">Sex</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="D3DOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    
                    <p>
                    	            <label>Dependant Name</label>
                    				<input class="field" type="text" name="dep4name" maxlength="60" />
                    				<select class="mini" name="D4Gender">
                    	                <option value="">Sex</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="D4DOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    
                    <p>
                    	            <label>Dependant Name</label>
                    				<input class="field" type="text" name="dep5name" maxlength="60" />
                    				<select class="mini" name="D5Gender">
                    	                <option value="">Sex</option>
                    					<option value="F">Female</option>
                    					<option value="M">Male</option>
                    	            </select>
                    				<input class="mini" type="text" name="D5DOB" value="MM/DD/YYYY" onClick="this.value = '';" maxlength="10" />
                    			</p>
                    
                    				
                        </fieldset>
                    
                            
                    			
                    
                    
                    
                    
                    	<p>
                    		
                    
                            <input type="image" src="[(base_url)]assets/images/layout/btn_continue.gif" name="frmGo" value="Continue" class="no_box" />
                        </p>
                    </form>

                    I’m thinking that because I edited everything to use only two form pages instead of three, as was given in the example at the start of this topic, I screwed something up along the way. If someone could have a look, I’ll be greatly appreciative!
                      • 8004
                      • 39 Posts
                      Quote from: bertcatsburg at Dec 09, 2007, 04:28 PM

                      Again, too fast.
                      I solved the problem by putting the MultiForms snippet in a copy of the eForm snippet itself. That was what solved it.
                      i cant understand how to putting the MultiForms snippet in a copy of the eForm snippet itself.
                      somebody can help ?
                        www.ekg-uralsnab.ru - экг 5а, колеса крановые шкивы, металлообработка