We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts

    IMPORTANT!
    Download Latest eForm Release..
    For support please post your requests in new dedicated eForm Support Forum.

    This topic is now closed, please post your support requests in new forums as a new topic.
    For more information please read this topic: eForm Documentation and Resources.



    Hi Everyone,

    I’ve created this form snippet sometime ago to allow me to easy create web forms and have those forms submitted via email.

    The snippet requires a web form and a web report. The webform and report can be easily created using the Rich text editor when creating a Chunk.

    To install upzip the eform.zip into the root of your modx website and then point your browser to http://www.yourdomain.com/install, where www.yourdomain.com is the name of your domain.

    Features:
    * Mobile email
    * AutoResponder
    * Multiple recipients
    * CC and BCC support
    * Basic form validation
    * File handliing

    Usage:
    Converts or save a web form into a email or html document
    This new document can be sent via email to specified user
    Main Features:form mail and save,auto-repond, report generation

    Params:
    &vericode (Optional)
    Enables verification code. The template contain a vericode
    field and a [+vericode+] placeholder

    &formid
    This is a unique id used to identity a form during postbacks
    This is useful in cases where more than one form exists on
    a page

    &to (Optional)
    Email address to send eForm information to
    For multiple receipent separate emails with a comma (,)
    If omitted the site settings email address will be used

    &from (Optional)
    Sets he email address to appear in the From section of the email

    &fromname (Optional)
    Sets the name of the sender in the From section of the email

    &sendirect (Optional)
    This will use the form field called email to supply the
    email address to send the message to.
    Set to 1 to activate send direct. Defaults to 0

    &cc (Optional)
    Same as &email but for Cc:

    &bcc (Optional)
    Same as &email but for Bcc:

    &ccsender (Optional)
    Set to 1 to send the user a copy of the submitted form. Defaults to 0
    eForm will look for the user’s email address inside a field called email.

    &subject (Optional)
    Subject to appear in email of datatile
    Can include [.form fields.]. E.g. Purcase Order for [.firstname.] [.lastname.]

    &noemail (Optional)
    Prevents eform from sending emails e.g. [email protected]
    Set to 1 to disable emails. Defaults to 0

    &mailselector (Optional)
    Sets the name of the form field to use as a selector to select
    a single email from the comma (,) delimited emails assigned
    the &to parameter. This selector field will act like a numeric
    index to select an email. It will start at 1 for the first email
    and ends at N for the last email in the list.

    For example:
    &to =`[email protected],[email protected],[email protected]`
    &mailselector=`topic`

    on the web form the topic fields is actually a dropdown menu.
    when the selects a topic from the list the value 1,2 or 3 will
    be sent to eForm which will then be used to select one of the
    three emails assigned to the &to parameter. This email address
    will be the address used to send the email to.

    &mobile (Optional)
    Mobile email address. This email is used to send a short
    notification message to a mobile device.

    &mobiletext (Optional)
    Text message to send to mobile device
    Can include [.form fields.]. E.g. Order for [.firstname.]

    &gotoid (Optional)
    document id to load after sending message

    &category (Optional)
    Category ID or name used to categorize eForms.
    If category is not found a new category will beb created
    This will appear in the subject of the email sent to the user

    &keywords (Optional)
    Comma delimited keywords or [.form fields.] used when searching databank
    E.g. [.firstname.], [.lastname.], [.email.]

    &autosender (Optional)
    email to display as sender of the auto-respond message
    e.g. [email protected]

    &automessage (Optional)
    chunk name (non-numeric) or document id (numeric) to use as an auto-responder message
    Can include [form fields]. E.g. [firstname]
    - tags: [form_fields],[postdate]
    - note: eForm will send the auto-respond message to the email address specified
    inside the [email] form field.

    &tpl (Optional)
    chunk name (non-numeric) or document id (numeric) to use as a template
    - tags: [+form_fields+],[+validatemessage+], [+postdate+]
    where form_fields is the name of the field used in a form

    &report (Optional)
    chunk name (non-numeric) or document id (numeric) to use when
    generating reports

    &allowhtml (Optional)
    Set to 1 to allow user to enter html tags. Defaults to 0

    &format (Optional)
    list of form fields that requires server-side validation
    - format: field_name:field_description:field_datatype:field_required
    - field_required: 0 or 1
    - field_datatype:
    string,
    date,
    integer,
    float,
    email,
    file - for file upload input
    listbox - for <select> boxes,
    checkbox - for <input checkbox>
    radio - for <input radio>,
    html - will converts \n to

    - Note: for listbox, checkbox, radio use [.field_name:field_value.] in order to reselect the correct item
    - Example: txtname:Name:string:1,txtage:Age:number:0,txtdob:Date Of Birth:date:0


    Basic Examples:
    [[eForm?&[email protected]&gotoid=1&tpl=orders]]

    [[eForm?
    &to=`[email protected]`
    &gotoid=`7`
    &category = `Purchase Order`
    &tpl=`purchase_order`
    ]]

    Example using a contact us form:

    [[eForm? &formid=`ContactForm` &to=`[email protected]` &mailselector=`destination` &tpl=`ContactForm` &report=`ContactReport` &category=`Contact Requests` &format=`destination:Department:string:1,topic:Topic:string:1,name:Name:string:1,email:Email:email:1,message:Message:html:1`]]


    For Simple form:
    [[eForm? &vericode=`1` &formid=`ContactForm` &to=`[email protected]` &gotoid=`1` &tpl=`ContactForm` &report=`ContactReport` &category=`Contact Requests` &format=`subject:Subject:string:1,name:Name:string:1,email:Email:email:1,message:Message:html:1`]]


    PHP Event Function:
    $eFormOnMailSent
    This function is called after email has been sent

    UPDATES: Please check the links below for added/updated features and information:
    updated/patched version by original author
    eForm Parser MOD by TobyL

    Few Important posts about eForm:
    http://modxcms.com/forums/index.php/topic,2122.msg34623.html#msg34623
    http://modxcms.com/forums/index.php/topic,2122.msg34702.html#msg34702

    NEW! A guide on the chunks etc needed for a simple working form by TobyL

    Please download latest PHPMailer class
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 7455
      • 2,204 Posts
      small bug in the installer
      the "eform.inc.php" is placed in:
      assets/snippets/
      while the snippet looks in :
      assets/snippets/eform/

      moved it to that folder now it works
        follow me on twitter: @dimmy01
        • 7455
        • 2,204 Posts
        I’ve bin playing with this but with no succes
        could you make an example package that i could use to see how it all works?

        I made a chunk called test in that chunk a simple form:
        <form name="test" method=POST action="" >
        <input type="file" name="file" size="16">
        <p><input type="text" name="Email" size="24">e-mail</p>
        <p><input type="text" name="name" size="24">naam</p>
        <p><input type="submit" name="submitButtonName"></p>
        </form>
        


        and called the snippet like this:
        [[eForm? &to=`mymailadres.com` &gotoid=`3` &tpl=`test` &formid='test']]

        it doesn’t go to page 3 ider it stay’s on the current page
        no error nothing

        it does show the form

        what do i do wrong?

        the mail never hits my mailbox
          follow me on twitter: @dimmy01
          • 32963
          • 1,732 Posts
          Quote from: Mod

          xwisdom: Hmmmm, Is the page cached?
          Dimmy: nope not cached
          xwisdom: Did you set the &formid parameter?
          Dimmy: &formid=`test` named the form in the chuck test or is this not the meaning of the formid?

          Here’s what &formid does
          &formid - This is a unique id used to identity a form during postbacks. This is useful in cases where more than one form exists on a page

          Inside your form add
          <input type="hidden" name="formid" value="MyForm" />

          In your document add

          [[eForm?formid=`MyForm` &to=`[email protected]`]]

          Here’s an example of a contact us form:

          <style>
          	.contactform tr td {
          		font-family:verdana,arial;
          		font-size:13px;
          		padding:1px;
          	}
          	.contactform input, .contactform textarea {
          		border:1px solid silver;
          	}
          </style>
          <form method='post'>
          <input type="hidden" name="formid" value="ContactForm">
          <div class="contactform">
          <table border="0" style="width:inherit">
            <tr>
              <td>Enter your information below then click the
              Send button <font color="#008000"> <br>
              </font><font color="#FF0000" size="1">*</font><font color="#808080"><span style="font-size: 9pt"> -
              Indicates Required fields</span></font></td>
            </tr>
            <tr>
              <td>
          <table border="0">
            <tr>
              <td><span style='color:red'>[+validationmessage+]</span></td>
            </tr>
            <tr>
              <td><b>Your name:</b> <font color="#FF0000" size="1">*</font><br />
                    <input size="32" name="name" value="[+name+]"><br />
          	 	  <b>Email address:</b> <font color="#FF0000" size="1">*</font><br />
                    <input size="32" name="email" value="[+email+]"><br />
                    <b>Subject:</b><br />
                    <input size="32" name="subject" value="[+subject+]"><br />
                    <b>Messages:</b> <font color="#FF0000" size="1">*</font><br />
                    <textarea name="message" rows="8" cols="37">[+message+]</textarea><br />
                    Enter the verification code <b>[+vericode+]</b> below: <font color="#FF0000" size="1">*</font><br />
                    <input name="vericode" type="text" size="10" />
                    </td>
            </tr>
            <tr>
              <td>
              <table border="0" width="100%">
                <tr>
                  <td align="right" width="100%"><input type='submit' name='cmdsend' value='Send' title='Submit form' /> 
          <input type='reset' name='cmdclear' value='Clear' title='Clear form' /></td>
                </tr>
              </table>
              </td>
            </tr>
          </table>
          </td>
            </tr>
            </table>
          </div>
          </form>
          


          Here’s the eForm code:

          [[eForm? &vericode=`1` &formid=`ContactForm` &to=`[email protected]` &gotoid=`1` &tpl=`ContactForm` &report=`ContactReport` &category=`Contact Requests` &format=`subject:Subject:string:1,name:Name:string:1,email:Email:email:1,message:Message:html:1`]]
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 7455
            • 2,204 Posts
            Ok thanks , lots of options to use. I ts not 100 clear to me yet but I get there, is it also easy to use a file upload input field?
            would i need to add [+file+] or somthing like that in the chunk as valeu for file?
            and what do I add in the snippet call for the snippet to handle the file upload?

            Thanks for the help so far

            Dimmy
              follow me on twitter: @dimmy01
              • 32963
              • 1,732 Posts
              Try this:

              In your form template use:
              <form method="post" enctype="multipart/form-data">
              <input name="formid" type="hidden" value="MyForm"/>
              <input name="myfile" type="file" size="28" />
              </form>

              In your report template use:
              [+myfile+]

              And in your web page use:
              [[eForm? &formid=`MyForm` &tpl=`myform` &report=`myreport` &to=`[email protected]` &format=`myfile:File upload:file:0`]]
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 7455
                • 2,204 Posts
                OK nice
                The file does hit my mailbox but as raw text not as an atachment (this is in outlook) in my webmail it is an atachment will try oulookexpress now.

                Outlook mail atached here:
                  follow me on twitter: @dimmy01
                  • 7455
                  • 2,204 Posts
                  OK found the solution

                  I just updated the PHPMailer class to 1.73 and it work like a charm
                  Thanks for all the help
                    follow me on twitter: @dimmy01
                    • 7455
                    • 2,204 Posts
                    Does it also chek if there is an input?
                    like if i would ask for an mail adres I like it to be validated if there is an input at all.

                    I have a complex form with some requierd fields, would be nice if the snippet checks for requierd fields and give an error if not all are filled in.

                    Dimmy
                      follow me on twitter: @dimmy01
                      • 32963
                      • 1,732 Posts
                      Sure it does. see the &format parameter
                        xWisdom
                        www.xwisdomhtml.com
                        The fear of the Lord is the beginning of wisdom:
                        MODx Co-Founder - Create and do more with less.

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