We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22815
    • 1,097 Posts
    EDIT: You’ve missed out the placeholder for warning messages.

    Quote from: Uncle68 at Sep 13, 2006, 06:36 AM

    But can I also format the eForm call so that I don’t need the "&report" template chunk?
    The "report" is actually the body of the email that you get when the form has been filled in. You can use a document instead of a chunk, but that’s it. You need the report. It is confusingly named, yes. The top post says this is optional. I don’t know why.
    Quote from: Uncle68 at Sep 13, 2006, 06:36 AM

    Oh, one more thing, could someone also explain the syntax for "text1:Text1:string:1", what does the three (four?) parts do?
    This is just the required fields and the type of data that must be filled in. - Human label, field name, data type. I’ve no idea what the number does, actually. Yes, this could be better documented.
    Quote from: Uncle68 at Sep 13, 2006, 06:36 AM

    Oh #2! Sorry, just one more question (for now): "<input type="text" name="text1" />" works for me, but in examples I’ve seen there is also value=[+text1+], like "<input type="text" name="text1" value="[+text1+]" />" What does that last part do?
    If you miss out a required field, the form is reloaded. The intention with setting the value is to pre-fill it with whatever you just filled in - so you don’t have to fill everything in again.

    EDIT: Come on everyone, lets get some real uses of this thing documented for people. It is hellishly confusing at present.
      No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
      MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
      Forum: Where to post threads about add-ons | Forum Rules
      Like MODx? donate (and/or share your resources)
      Like me? See my Amazon wishlist
      MODx "Most Promising CMS" - so appropriate!
      • 31037
      • 358 Posts
      Quote from: PaulGregory at Sep 13, 2006, 07:41 AM

      EDIT: Come on everyone, lets get some real uses of this thing documented for people. It is hellishly confusing at present.

      Thank you very much for your very clearifying answer!

      I agree that the documentation for this snippet is poor. There are some examples here, but they are filld with lots of other stuff, makes it hard to understand. And also there is no description whats happening when I do this and that.

      To add a form should take a few minutes, not several hours by trial and error. People like me evaluting MODx gets very confused tongue

      If my English where better I would write a tutorial from a newbies point of view. I could do it in Swedish, but I guess that wold be of no help wink

      Again, thanks for your help! smiley
        • 31654
        • 238 Posts
        EDIT: Come on everyone, lets get some real uses of this thing documented for people. It is hellishly confusing at present.

        I totally agree with Paul. Can eForm be moved to the Repository and get some propper documentation (and confusing tags renamed)?

        I have the form working but I’m not completely clear how... I had to just blindly copy and paste lots of it

        It’s a great snippet, just needs a little more work grin
          Web Development, Web Hosting & Search Engine Marketing by:

          Vitalized | UK
          w. www.vitalized.co.uk

          Website Design | Search Engine Marketing (SEM) | UK MODx web hosting, secure, fast & 100% MODx compatible

          Vitalized | Australia
          w. www.vitalized-australia.com.au

          Website Design | Search Engine Marketing (SEM) | Australian MODx web hosting, secure, fast & 100% MODx compatible
          • 22815
          • 1,097 Posts
          I believe that the next version of eForm will be added to the Repo, and that’s why the existing version hasn’t been. I don’t know how radically different that will be.

          How about this basic outline for documentation?

          * Complete guide on adding a basic "email, name, comments" form - INCLUDING the creation of a success page, and a usable form chunk, report chunk.
          * How to add server validation
          * How to add CAPTCHA
          etc.

          Start with the basics and then add to it. Any thoughts?

          EDIT: I’ve just tidied this thread up a bit, and it is now 2 pages shorter - hopefully easier to get through. Confusingly the first full example is for an advanced usage with file uploads.
            No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
            MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
            Forum: Where to post threads about add-ons | Forum Rules
            Like MODx? donate (and/or share your resources)
            Like me? See my Amazon wishlist
            MODx "Most Promising CMS" - so appropriate!
            • 24278
            • 165 Posts
            Hi members,

            How can I set the maximum file size for an attachment?

            best regards,

            Raavi
              • 30223
              • 1,010 Posts
              How about this basic outline for documentation?

              * Complete guide on adding a basic "email, name, comments" form - INCLUDING the creation of a success page, and a usable form chunk, report chunk.
              * How to add server validation
              * How to add CAPTCHA
              etc.

              Alright,... here’s a simple example of a ficticious feedback form: This is assuming you’r using eForm with the eFormParser... I’ve included the vericode (CAPTCHA) markup so you can see how this can be added to the form.

              Don’t know about server validation though. In the current version eForm has some very basic validation but beside hacking the snippet there is not really any way of adding more server validation. Hopefully this will be added in a next version. I’ve raised this in a previous message.


              Step 1. Create the form and place it in a chunk. lets call it ’eFeedbackForm’
              <p><span style="color:#900;">[+validationmessage+]</span></p>
              <form method="post" action="[~[*id*]~]">
              	<input type="hidden" name="formid" value="feedbackForm" />
              	
              	<p><label accesskey="n">Your Name</label>
              	<input type="text" name="Name" maxlength="60" eform="Your Name::1" /></p>
              
              	<p><label accesskey="e">Your Email Address</label>
              	<input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" /></p>
              	
              	<label accesskey="s">Subject</label>
              	<select name="subject">
              		<option value="Feedback">Website feedback</option>
              		<option value="Support request">Support request</option>
              		<option value="Feature Request">Feature request</option>
              	</select>
              	
              	<p><label accesskey="c">Comments</label><br />
              	<textarea cols="40" rows="10" name="comments" eform="Comments:html:1"></textarea></p>
              
              	<p><label">Would you like to be on our mailling list?</label>
              	<input type="radio" name="list" value="Yes" eform="Mailling List::0:" /> Yes 
              	<input type="radio" name="list" value="No" /> No </p>
              
              	<p>
              	Please enter the verification code below: (to prevent spam)<br />
              	<img src="[+verimageurl+]" alt="verification code" /><br />
              	<input type="text" name="vericode" size="20" />
              	</p>
              	
              	<p><input type="submit" name="submit" value="Send Feedback"></p>
              </form>
              


              Step 2. Create an email template (the report template) and place it in a chunk. Let’s call this one ’eFeebackReport’
              <p>This is a response sent by [+Name+] using the feedaback form on the website. The details of the mesage follow below:</p>
              <table>
              <tr valign="top"><td>Name:</td><td>[+Name+]</td></tr>
              <tr valign="top"><td>Email:</td><td>[+email+]</td></tr>
              <tr valign="top"><td></td><td>[+subect+]</td></tr>
              <tr valign="top"><td>comments:</td><td>[+comments+]</td></tr>
              </table>
              <p>Would [+name+] like to be on our mailing list? <strong>[+list+]</strong></p>
              
              <p>You can use this link to reply: <a href="mailto:[+email+]?subject=RE:[+subject+]">[+email+]</a></p>
              


              Step 3. (optional) Create a thank you page. Let’s assume this will have the page id 34.
              <h3>Thank You!</h3>
              <p>We do appreciate your feedback. Your comments have been submitted to our office and hopefully someone will bother to actually read it.</p>
              <p>Please be assured that we will do our best not to ignore you, but if today's a Monday please try again in a few days.</p>
              


              EDIT: Forgot to mention this. Although you can create a thank you page, at the moment there is no way of using any of the form data on this page. Don’t bother putting placeholders in your thank you page. It won’t do you any good.

              Step 4. Add the snippet call to a (new) page.
              [[eForm? &formid=`feedbackForm` &to=`[email protected]` &tpl=`eFeedbackForm` &report=`eFeedbackReport` &gotoid=`34` &vericode=`1`]]
              


              That’s it!

              The format of the eform (pseudo) attribute is similar to the &format parameter except you do not need the field name: [human name]:[data type]:[0 or 1]. The 1 stands for ’this field is required’

              Hope this helps seomone.

                • 33337
                • 3,975 Posts
                Zaigham (aka zi) Reply #207, 20 years ago

                Thank You!
                We do appreciate your feedback. Your comments have been submitted to our office and hopefully someone will bother to actually read it.
                Please be assured that we will do our best not to ignore you, but if today’s a Monday please try again in a few days.

                :D ...

                But very nice example Toby! Thank you very much!

                regards.

                zi
                  Zaigham R - MODX Professional | Skype | Email | Twitter

                  Digging the interwebs for #MODX gems and bringing it to you. modx.link
                  • 31037
                  • 358 Posts
                  Quote from: TobyL at Sep 13, 2006, 12:03 PM

                  Hope this helps seomone.

                  Yes, it sure does! Thank you *very* much. I wish I had that information last night, then I might not be so tiered today. 3 hours sleep isn’t enough I think smiley

                  So if I understand correctly,
                  <input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" />
                  is the same as the "old" way to do it:
                  &format=`email:Your Email address:email:1`


                  And both of them creates the content of a placeholder named [+email+] which I can use in the report template?

                  I think I’m getting this smiley
                  It’s easy just coping the examples and modifying them to work as you want, but I have 16 sites to create, so I really want to understand *why* it works! smiley

                  I’m still not sure what the "data type" field does, but I guess it has to do with the validation. And also I’m wondering about how "<img src="[+verimageurl+]" alt="verification code" />" works.

                  Hmmm, more things I don’t feel I know how it works:

                  [+validationmessage+], is that the text they get if the validation not "validates"? Where does that text come from?

                  I don’t expect some one to answer all my questions in this post, I just write down what comes up my mind when reading the example. I’ll read all of this thread one more time, I guess that will help me understand all of it.

                  If someone is going to write more on this tutorial, please add something about what is needed to add the possibility to attach a file to the form.

                  Also I think I read that it’s possible to automatically generate a document when someone is using the form, but I might have missunderstood that?

                  Again, you don’t need to answer all this, just my random thoughts. When reading the thread one more time I guess it all come clear to me!

                  Sorry for my bad English smiley


                  EDIT: Should there not be a "call" to eform here?
                  <select name="subject">
                  		<option value="Feedback">Website feedback</option>
                  		<option value="Support request">Support request</option>
                  		<option value="Feature Request">Feature request</option>
                  	</select>
                  I guess I should add it to the first line?
                    • 24278
                    • 165 Posts
                    Hi members,

                    Installed eform snippet and parser on my Modx 0.9.2.1 and I get the following error on execution:

                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »
                     
                    PHP error debug
                      Error: 	array_values(): The argument should be an array	 
                      Error type/ Nr.: 	Warning - 2	 
                      File: 	/usr/www/users/test/manager/includes/document.parser.class.inc.php(705) : eval()'d code	 
                      Line: 	372	 
                     
                    Parser timing
                      MySQL: 	0.0168 s s	(19 Requests)
                      PHP: 	0.0516 s s	 
                      Total: 	0.0684 s s	 

                    Line 372 in my document.parser.class.inc.php contains the line below...
                    $poweredby ="Powered By <a href='http://www.modxcms.com/' title='Content managed by the MODx Content Manager System'>MODx</a>.";
                        }
                    


                    All help on this issue is appreicated.

                    -Raavi
                      • 30223
                      • 1,010 Posts
                      Quote from: Uncle68 at Sep 13, 2006, 02:35 PM


                      So if I understand correctly,
                      <input type="text" name="email" size="40" maxlength="40" eform="Your Email Address:email:1" />
                      is the same as the "old" way to do it:
                      &format=`email:Your Email address:email:1`


                      Yes, that’s correct. Before the eFormParser was introduced the former method (&format-=`...`) was the only way of setting the formatting values.

                      A little more about eFormParser
                      eFormParser was written because, with large forms, the snippet call could become very long and unreadable (at least all required fields would need to be listed in the &format parameter). eFormParse takes away the need for this as it uses a pseudo attribute in the form fields to achieve the same thing. It also relieves the need of adding most placeholder tags in the form as it will automatically generate them based on the field name (although you still need them in the report template). It used to be that by the time I’d created the form and the report template and was writing the snippet call I’d forgotten most of the fieldnames. My bad memory has been the main driving force behind writing the eFormParser smiley

                      It is still possible to use the old style &format=`...` parameter but be aware that you can not use both at the same time! When you place a &format parameter in your snippet call the form will not be parsed by eFormParser at all! This was done for backward compatibility.



                      And both of them creates the content of a placeholder named [+email+] which I can use in the report template?

                      Yes, as explained above.


                      I’m still not sure what the "data type" field does, but I guess it has to do with the validation.

                      Sort of yes,.. eForm does some rudimentary vaildation according to the data type. There’s an explanation of the different datatypes in the snippet comments (or in a separate readme.txt file). I’ll repeat it here for you though:

                      Common validation: All fields that are required will be checked if they are left empty.

                      • string - validation: No specific validation besides checking if it’s empty if the field is required.
                      • date - validation: check if it is a valid date (based on php’s strtotime() function)
                      • integer - validation: check if it is a number (does not check if it is in fact an integer)
                      • float - validation: check if it is a number
                      • email - validation: check if it’s a valid email address using a simple regular expression
                      • file - (for file upload input) - checks if a size error occurs, does not currently check file type I believe
                      • listbox - (for <select> boxes) - see comments below.
                      • checkbox - (for <input checkbox>) - see comments below.
                      • radio - (for <input radio>) - see comments below.
                      • html - Same as string except that it converts line endings (\n) to
                        tags

                      When using the eFormParser (see paragraph above) the listbox, checkbox and radio data types are no longer required. eFromParser will recognize them anyway. It will validate the values against the list of values you’ve placed in the form template (which will eliminate tampering with values on those fields). If you are using the &format paramter you should read the comments in the snippet on how to deal with values and placeholders.

                      ----
                      EDIT 15 Sep 06
                      Although it looks like the form validation in eForm is rather limited at the moment you should be aware that all POST and GET variables already have been stripped of some of the more common manipulation attempts by MODx’s index.php.
                      ----


                      And also I’m wondering about how "<img src="[+verimageurl+]" alt="verification code" />" works.

                      Simple. When you add the &vericode=`1` parameter to the snippet call eForm will replace the [+verimageurl+] with the CAPTCHA generated image. ( /manager/includes/veriword.php?rand=[some generated number]). The "<input type="text" name="vericode" size="20" />" field is then validated against the text in the image when teh form is submitted.


                      [+validationmessage+], is that the text they get if the validation not "validates"? Where does that text come from?

                      Yes, again that’s correct. The text is generated by eForm (see the code starting at line 150 in eform.inc.php) and it uses the [human name] value you’ve put in the eform pseudo attribute or in the &format parameter. For instance you have an email field in your form like this: <input type=’text’ eform=’Your email address:email:1’> (a required field indicated by the 3rd value - 1). Now if they forget to fill it in you’d get the error message "Your email address is required." If they filled in an invalid email address teh message would be: "Your email address is not a valid email address" (italics added for clarity)


                      If someone is going to write more on this tutorial, please add something about what is needed to add the possibility to attach a file to the form.

                      Just add "<input type="file" name="fileAttachment" eform="File Attachment:file:0">" (not required in this case). If the file is accepted by the server it will be attched to the email send out by eForm. eForm itself does not validate the file type or size. It relies (as far as I know) on the underlying server and php upload limits. I don’t think that the upload limit as set in the MODx system configuration applies in this case. Perhaps someone can confirm this?

                      ----
                      EDIT 15 Sep 06 - 2 extra requirements for file uploads I missed to write down.
                      Firstly you’ll have to set the the form to multipart/form-data , something like this: <form method="post" enctype="multipart/form-data">
                      Secondly you might need to set a placeholder in your report. In the example above this would be [+fileAttachment+].
                      ----


                      Also I think I read that it’s possible to automatically generate a document when someone is using the form, but I might have missunderstood that?

                      Yes, you have misunderstood that. I believe this was in the planning for a future release or perhaps just an idea that was raised. It certainly isn’t possible in the current version.


                      EDIT: Should there not be a "call" to eform here?
                      <select name="subject">
                      		<option value="Feedback">Website feedback</option>
                      		<option value="Support request">Support request</option>
                      		<option value="Feature Request">Feature request</option>
                      	</select>
                      I guess I should add it to the first line?

                      Not necessarily in this case but if you wanted this to be a required field or have it validated then yes you could add something like eform="Form Subject::1" (note that there’s no data type here as it is not needed)

                      EDIT: Adding it to the select tag that is...

                      Quote from: Raavi at Sep 13, 2006, 10:45 AM

                      How can I set the maximum file size for an attachment?

                      As you can read above there’s no way of doing that in eFrom that I know of. You’ll have to dive into the php ini settings for that (upload_max_filesize I believe).

                      Hope this really clarifies things

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