We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30223
    • 1,010 Posts
    Well Bugger me! Not having a good day. Once more and I’ll demote myself. smiley

    Done.


      • 24292
      • 28 Posts
      sendAsText is not working in V1.4.3
      eform.inc.php has the wrong variable name
      $isHtml = ($sendAstText===1 || strstr($sendAsText,'report'))?false:true;

      but even when corrected to $sendAsText it still doen’t work.
      I have just changed my copy to
      $isHtml = !($sendAsText==1);

      to get it to work for now.

      Also, would it be possible to set $mail->Encoding = ’7bit’ and to not set $mail->CharSet when sending plain text, or at least to make it possible to do that, as that’s the default plain text format.
        • 30223
        • 1,010 Posts
        Well spotted! I had to look twice even now to see the the extra ’t’ in there. However your solution isn’t ok either. It might work for your particular situation but it doesn’t fully fit the bill either as some people may have already used the second variant - &sendAsText=`report`.

        If setting &sendAsText=`1` does not work perhaps the first test ( $sendAsText===1 ) is to strict.. It checks type as well as value and expects an integer but if the parameter is somehow interpreted as a string this might fail. I’ll have to check this but if you change the first test to $sendAsText==1 you might get better results.

          • 27376
          • 576 Posts
          Suggestion:

          TobyL, could you make the ’eFormOnBeforeFormParse’ event also pass the $isPostBack variable to the funtion? This would help make it easier for developers to code a function to pre-load a form with info. Like so:
          <?php
          function MyeFormOnBeforeFormParse(&$fields, &$templates, $isPostBack) {
              if (!$isPostBack) {
                  // We're not posting data, pre-load some input from db or something...
              }
          }
          ?>

          Thanks smiley

          Also, in reply to the &sendAsText conversation, why not make it:
          <?php
          $isHTML =  ($sendAsText == '1' || strstr('report', $sendAsText)) ? false : true;
          ?>
            • 23491 ☆ A M B ☆
            • 1,056 Posts
            <?php
            $isHTML = ( (int) $sendAsText == 1 || stristr( 'report', $sendAsText ) ) ? false : true;
            ?>


            What about data type declaration, and case-insensitive pattern matching via (int) and stristr() respectively?
              Mike Reid - www.pixelchutes.com
              MODx Ambassador / Contributor
              [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
              ________________________________
              Where every pixel matters.
              • 27376
              • 576 Posts
              Typecasting would not be required when using ($sendAsText == ’1’) because the if the variable is an integer, the parser will cast it as a string, if it is a string, then we’re good smiley

              Typecasting would only be needed if you’re using three equal signs (===).... I think....

              but case insensitive matching slows down the parser, just tell the programmers it needs to be lowercase. I would only use case insensitive matching if I were capturing input from a user, but programmers should program for parsing speed, not laziness of other programmers.

              </rant>
                • 23491 ☆ A M B ☆
                • 1,056 Posts
                Well said wink
                  Mike Reid - www.pixelchutes.com
                  MODx Ambassador / Contributor
                  [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                  ________________________________
                  Where every pixel matters.
                  • 30223
                  • 1,010 Posts
                  Programmers are lazy! That’s why they are programmers, why do something twice if a few lines of code can do it infinite times.. grin

                  The only change needed is the one already discussed.. ($sendAsText == ’1’) . That is what it is going to be...

                  A bit beside the point as I’m not going to introduce case insensitive matching, but the input is coming from users and not necessarily from programmers. Whoever sets the snippet parameters (any content editor) may well be someone who’s never even heard of PHP or have any other programming skills.

                    • 21257 MODX Staff
                    • 730 Posts
                    Hi,

                    I’m using eForm for the first time on a project, and I had to modify some code in eform.inc.php yesterday in order to get the snippet to send email.

                    Line 392 was:
                    if(empty($to) || !strpos('@',$to)) $nomail=1;
                    


                    And I changed it to:
                    if(empty($to) || !strpos($to,'@')) $nomail=1;
                    


                    Maybe this was some weird version glitch on my side, because I don’t see anyone else in this thread having a problem sending email.

                    Thanks for the great snippet.
                      Mike Schell
                      Lead Developer, MODX Cloud
                      Email: [email protected]
                      GitHub: https://github.com/netProphET/
                      Twitter: @mkschell
                      • 23491 ☆ A M B ☆
                      • 1,056 Posts
                      Yikes! I guess it is possible, since I’m using eForm2db example I prepared along w/ &noemail=`1`. While I do not require email, I certainly enjoy the custom, server side validation prior to db insertion...
                        Mike Reid - www.pixelchutes.com
                        MODx Ambassador / Contributor
                        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                        ________________________________
                        Where every pixel matters.

                      This discussion is closed to further replies. Keep calm and carry on.