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

    Can get this form to work without any problems. However when a required form field isn’t filled in there is no error message. Am I supposed to add anything to display the errors?

    When a required field is missing, it just reloads the page . . . my guess is that it knows what the missing field is (otherwise it would, and does, send the form) but it doesn’t tell the user anything.

    Any ideas?

    Thanks!

    [RESOLVED]
    Sorry . . . being really dumb . . . forgot to add the [+validationmessage+] placeholder to the form chunk!
      • 20751
      • 122 Posts
      This has had me banging my head against the wall all afternoon but finally realized what I was doing wrong . . . I hope this will save someone a lot of heartache.

      This is an awesome and powerful script but be mindful of two things if you want select boxes, check boxes, and radio buttons to be remembered on error:

      1. Add the fields you want remembering to the &fromat paramater, even if they’re not required. So if I had a form with 2 lists, one with myfavoritecolor which was required, and one with myfavoritesong that was not required here’s what the &format paramater would look like:

      &format=`myfavoritecolor:My Favorite Color:listbox:1,myfavoritesong:My Favorite Song:listbox:0`


      2. With really long lists of options for the &format parameter the temptation is to put each on a new line like this:

      &format=`myfavoritecolor:Myy Favorite Color:listbox:1,
      myfavoritesong:My Favorite Song:listbox:0,
      myfavoritefood:My Favorite Food:listbox:0,
      myfavoritecms:My Favorite CMS:listbox:0`


      When separating options onto new lines and then pasting into a RTE inside MODx, the lists and checkboxes were no longer remembered when an error occurred, my guess because putting the &format options on new lines as above, created spaces between each field option. This happened even when using notepad and ensuring no space was at the end of each line.

      Ensuring that all of the options were on one line without any spaces fixed the problem! Now all my checkboxes are remembered and list box choices are remembered if there is an error!

      Whew! Hope that helps someone . . . just don’t ask me why it happens!


        • 16095
        • 35 Posts
        Thank you myan24, good tip!!!
          • 30223
          • 1,010 Posts
          This has had me banging my head against the wall all afternoon but finally realized what I was doing wrong . . . I hope this will save someone a lot of heartache.

          This is an awesome and powerful script but be mindful of two things if you want select boxes, check boxes, and radio buttons to be remembered on error:

          Perhaps this eform hack I’m working on would have been of help to you.. I was going to do some more work on it before posting it but I might as well share it with you now. I’ve added a form-parser to eForm which will let you declare all the format options in the form template itself instead of in the snippet call. I find this much easier, especially with larger forms.

          Besides the [+vericode+], [+verimageurl+] and [+validationmessage+] placeholders you no longer need to add placeholders to the form fields nor do you need to add the &format parameter to the snippet call. You set format parametes from within the form fields themselves. The format parameter is build from a pseudo attribute added to the form field. The format has (almost) remained the same except that you should skip the field-name and that the field_datatype can be left empty for checkboxes, radio, select and plain text boxes (string).

          Hopefully everything is clear from the example below and the comments in eFormParse.inc.php

          <p><span style="color:#900;">[+validationmessage+]</span></p>
          <form method="post">
          <input type="hidden" name="formID" value="testFrom" />
          <table>
          <tr valign="top">
          	<td>Name</td>
          	<td><input type="text" name="fullName" maxlength="60" eform="Your Name::1:" /></td>
          </tr>
          <tr valign="top">
          	<td>Email</td>
          	<td><input type="text" name="email" size="40" maxlength="40" eform="Email Address:email:1" /></td>
          </tr>
          <tr valign="top">
          	<td>Any Ideas?</td>
          	<td>
          		<input type="radio" name="frmIdea" value="Yes" eform="Any Idea::1:" /> Yes 
          		<input type="radio" name="frmIdea" value="No" /> No 
          		<input type="radio" name="frmIdea" value="Maybe" /> Maybe 
          		<input type="radio" name="frmIdea" value="Dont Know" /> Don't Know
          	</td>
          </tr>
          <tr valign="top">
          	<td>Language</td>
          	<td><select name="frmLanguage">
          		<option value="en-au">AU English</option>
          		<option value="en-gb">UK English</option>
          		<option value="en-us" selected="selected">US English</option>
          </select></td>
          </tr>
          <tr valign="top">
          	<td></td>
          	<td></td>
          </tr>
          </table>
          </form>
          


          And the simplified snippet call:
          [!eform? &formid=`testForm`  &to=`[email protected]` &gotoid=`1` &tpl=`testForm`!]


          I’ve had to hack eForm.inc.php so make sure you replace it with the one in the zip file. It also contains some of the other updates mentioned in this thread (the’ve all be commented in the file).

          Edit 10 July 06: Updated eFormParse - corrected handling of vericode input tag. see http://modxcms.com/forums/index.php/topic,2122.msg40248.html#msg40248

            • 33372
            • 1,611 Posts
            I still haven’t had a chance to experiment with your eParse mod of this snippet, but it looks like a great idea.
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 32963
              • 1,732 Posts
              TobyL,

              Absolutely brilliant!!!!!!!!!!!!!!! I LOVE it!

              It’s very simple and easy to use.

              Two other features came to mind after looking at your code:

              1) Doc-IT- Save posted eforms directly to a modx document/folder.

              2) Auto-Print - Automatically print the eForm Report after it’s posted.

              I can see the above being very useful in generating order forms and survey reports.




                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.
                • 20751
                • 122 Posts
                Nice work TobyL!

                I use eform for a long booking form for conference facilities so this will come in very handy!

                I totally love the idea of a Doc-IT feature xwisdom . . . hope to see that in the near future!!

                Thanks guys . . .
                  • 30223
                  • 1,010 Posts
                  Humbly bows in front of modx master... Thanks for those encouraging words. wink


                  1) Doc-IT- Save posted eforms directly to a modx document/folder.

                  2) Auto-Print - Automatically print the eForm Report after it’s posted.

                  Food for thought indeed. I’ll put my thinking cap on. First of all though I want to make the forms more secure, in fact that’s where this all started for me. I want to extend the the form fields by adding some sort of @bindings validation to the eform pseudo-attribute. If you have a carefull look at the eFormParse code you’ll see the beginnings of it already. See line 108-109.

                  My ideas are this to start with:

                  Select boxes, radio options and checkbox fields can have an automatic validation eFormParse would build a list of the values from the form template chunck and any input would validated against that list. Anyone trying to tamper with the form and add their own values to these fields will be caught out immediately. A field with data_type ’email’ is also automatically checked although I think you should be able to override this.

                  For other validation options I’m thinking of this:

                  @LIST - Comma separated list of valid values
                  @SELECT - List of valid values retrieved from a query
                  The query should probably return a single column of values?
                  @FUNCTION - Name of a php validation function (which has to exist offcourse)
                  Extra parameters could be added using some kind of separator?
                  @EVAL - String of php code. Should probably return either true or false
                  @REGEX - Regular expression -syntax as for preg_match() - see php manual

                  @FILTER - Filters the input instead of validating it.
                  should be able to use @FUNCTION, @EVAL and @REGEX


                    • 7131
                    • 83 Posts
                    With MODx 0.9.2.1, I obtain:

                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: Unknown: failed to open stream: No such file or directory
                    Error type/ Nr.: Warning - 2
                    File: [(my_root)]/manager/includes/document.parser.class.inc.php(705) : eval()’d code
                    Line: 192

                    Parser timing
                    MySQL: 0.0056 s s (4 Requests)
                    PHP: 0.0521 s s
                    Total: 0.0578 s s

                    Is it a bug?
                      at the edge of dawn,
                      you ask yourself if your shadow did follow you down
                      all night long
                      • 7923
                      • 4,213 Posts
                      Quote from: dernier_recours at Jun 13, 2006, 05:10 PM

                      With MODx 0.9.2.1, I obtain:

                      ...

                      Is it a bug?
                      It seems that in the code, the snippet is looking for the eform.inc.php file from "assets/snippets/eform/eform.inc.php" but in the zip file it is in "assets/snippets/eform.inc.php", so try to create the eform folder under snippets and move the eform.inc.php to that folder.


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."

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