We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22151
    • 30 Posts
    Really when I coding, nothing is simple.

    So my call to snippet runs beautifully in the chunk "Thanks" for eForm but it is not interpreted in the "report". In other words, it is not interpreted in the email sent.

    Yet the same call the same snippet.
    Someone knows this bug?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The report needs placeholders [+...+] that are the same as the name attributes of the form fields. Other than that, the report can have any email-suitable HTML.

      If you need to add other dynamic items to the report, you can use a snippet with a function to add them to eForm’s "fields" array and then use placeholders for them. For an example of this, here’s my eForm call for my Contact page
      [!getServer!]
      [!eForm? &formid=`ContactForm` &tpl=`ContactForm` &report=`ContactReport` &subject=`sottwell.com Contact` &thankyou=`ThankYou` &from=`[+email+]` &fromname=`[+name+]` &replyto=`email` &debug=`1` &eformOnBeforeMailSent=`getServer` &eformOnValidate=`checkField`!]
      

      Here’s the getServer snippet and function
      <?php
      function getServer( &$fields ){
      	        // remote_addr
      		$fields['remote_addr']=$_SERVER['REMOTE_ADDR'];
                      $fields['remote_host']=$_SERVER['REMOTE_HOST'];
                      $fields['user_agent']=$_SERVER['HTTP_USER_AGENT'];
      		//return succes
      		return true;
      	}
      ?>

      and my report chunk
      <h3>Contact Input</h3>
      <strong>Name:</strong> [+name+]<br />
      <strong>Email:</strong> [+email+]<br />
      <strong>Message:</strong> [+message+]<br />
      <strong>IP:</strong> [+remote_addr+]<br />
      <strong>Host:</strong> [+remote_host+]<br />
      <strong>User Agent:</strong> [+user_agent+]
        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
        • 22151
        • 30 Posts
        Thank you very much sottwell for your response smiley

        I tried your solution but it seem’s match for my case.
        I will better explain my trouble.


        My eform give a list with checkboxs : [+photo+].
        I format [+photo+] with a snippet:
        [[retriveImages? &query=`[+photo+]` &chemin_thumb=`/assets/images/phototheque/.thumb_` ]]
        
        <?php
        $query_array = explode(', ',$query);
        foreach($query_array as $value) {
                 $result.="<img src=\"".$chemin_thumb.$value."\" style=margin:10px >\n";
                 }
            return $result;
        ?>


        I put this snippet call in the chunk "Thanks" and everything works well on the website.
        I put this snippet call in the chunk "Report" for sending email and that’s where this snippet is not interpreted ...

        an idea?