We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    Hi.

    I am making a form which will send a report to admin based upon a similar script I made for a different site using the &eFormOnMailSent function.

    However whenever I press submit on my form the page goes blank, but my tailor made e-mail message still gets sent.

    The form has a vericode on it, but even if I remove the vericode the form always redirects to a blank page and I don’t know why.

    I also have friendly URLs on, but even if I switch them off the page always redirects to a blank page.

    Here’s the eform call;

    
    [[eFormEventFunctions]]
    
    [!eForm?   &eFormOnMailSent=`dothistest`  &vericode=`1` &formid=`feedbackForm` &subject=`Website contact submission` &to=`[email protected]`  &report=`eFeedbackReport` &thankyou=`eFeedbackThanks` &from=`[email protected]` &fromname=`[(site_name)]`  &tpl=`tpl_contactform` !]
    
    


    The form is very simple at the moment;

    <p>[+validationmessage+]</p>
    
    <form method="post" action="[~[*id*]~]">
        <input type="hidden" name="formid" value="feedbackForm" />
    
        <p><label for="Name">Your Name *</label><br />
        <input type="text" id="Name" name="Name" maxlength="60" eform="Your Name::1" /></p>
    
         <p>
        Please enter the anti spam code below:<br />
        <img src="[+verimageurl+]" alt="verification code" border="1"/>
        </p>
    
        <p>
    <label for="vericode">code</label>
    <input type="text" name="vericode" size="20" />
        </p>
    
        <p><input type="submit" name="submit" value="Send" /></p>
    
    </form>
    


    And my eformfunctions are very simple too;

    <?php
    // eFormEventFunctions snippet
    function dothistest (&$fields){
    global $modx;
    global $templates;
    die("I'm inside the :" . __FUNCTION__);
    } // end function
    ?>
    


    When I remove all calls to the eFormEventFunctions the form displays and reloads properly, but when I put them in all that happens is that the page goes blank and I’m not sure why.

    Is there any reason why the page would go blank when I press ’submit’?




      • 32645
      • 377 Posts
      I decided to code the form from scratch, doing one bit at a time and testing -- it appears that there is something wrong with my form, or with my call -- but regardless I think with a little more digging I can solve this problem.

      Thank you for your help.
        • 30223
        • 1,010 Posts
        Let me help you out of your misery smiley

        Your event function must return true, that’s all...

        <?php
        // eFormEventFunctions snippet
        function dothistest (&$fields){
           global $modx;
           //do whatever you need to do....
           //RETURN TRUE! Very important!
           return true;
        } // end function
        ?>


        When the event functions evaluates to false eForm simply stops dead and returns nothing, hence a blank page.
          • 8471
          • 333 Posts
          Hi, I’m using a form like the example "Using eForm’s eformOnBeforeMailSent event" of the documentation. But In the page where I have called eFormEvent and eForm I receive this message:
          Parse error: syntax error, unexpected ’{’, expecting ’(’ in /var/www/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 6
          and under it I can see my forms without any problems.
          I think that I have wronged something in the eFormEvent snippet... anyone can check it for me? Thanks
          <?php
          //functions for eForm events
          function createJobNumber( &$fields ){
          global $modx;
          $jobNum = '';
          		foreach{ explode(' ',$fields['cognome'],3) as $nm)
          			$jobNum .= strtoupper(substr($nm,0,1));
          		$jobNum .= date('ymdHi');
          		//set extra value in fields array
          		$fields['jobNumber']= $jobNum;
          		//return succes
          		return true;
          
          	//rest of function code as above
          }
          //return empty string
          return '';
          ?>
            Sorry for my bad English grin
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Like the error says, on line 6 of your snippet, you’ve got a { instead of a ( in your foreach statement.

            foreach{ explode(' ',$fields['cognome'],3) as $nm)
              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
              • 8471
              • 333 Posts
              Thanks a lot!! laugh
                Sorry for my bad English grin
                • 32645
                • 377 Posts
                I’m really frustrated with this.  

                The EformFunctions is making my page go blank.  I don’t know why its happening, or how to prevent it from happening now or in the future. 

                My code is meant to run a piece of code I’m writing.  I had it working last night, but now it doesn’t do anything at all.  I’ve stripped down my code to a basic return function, but regardless of what I do the page goes blank either when I press submit, or worse; when I visit the page.

                How do I switch on MODX debugging?  How do I stop the page from going blank?  UGH!

                [[eformfunctions]]
                [!eForm? &formid=`ContactForm` &subject=`[(site_name)] Newsletter Sign-up` &to=`[email protected]` &from=`[email protected]` &tpl=`xContactForm` &report=`xContactFormReport` &noemail=`1` &thankyou=`xContactFormReport` &protectSubmit=`0`  &eFormOnValidate=`testfunction` !]
                


                // Snippet: eformfunctions
                
                function testfunction() 
                {
                return true;
                }
                


                [EDIT]

                Whenever I go to the page and the page never appears. No form, no errors, nothing.  It seems like MODX does not like functions in its snippets.  If I try to include an external php file from my modules/snippets folder and this external php file has a function - it still causes the same problem.

                I get no messages, nothing!  What is going on?!


                [EDIT]

                I think I now have fixed the issue.