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

    I’m working with eForm, it’s my second to last hurdle to overcome for this MODx site I’m building. I’ve got everything installed and I’m trying to figure out how to do two things:

    1. Get the form to validate, ie: if the user hasn’t filled out a form field, but clicks the "submit" button, they receive a message stating such.
    2. Add the following custom fields: Phone, Address, City, State, Zip.

    There is a screenshot that shows where I am so far.

    Any advice on how to achieve this would be great, thanks in advance!

    Cheers,
    msflux.

      • 30223
      • 1,010 Posts
      Start by reading the documentation in the assets/snippets/eform/docs/ folder of your modx installation. There’s an explanation for all available eForm snippet parameters, how to set the eform pseudo attribute in your form fields and examples. That should give you enough to build your form. After that try the wiki and If your still stuck ask specific questions here.



        • 24495
        • 407 Posts
          • 20508
          • 157 Posts
          Well, the form is setup as the previous screenshot I attached shows - I had no problem with that. However, when I click "submit" nothing happens, the form looks like it’s processed, but it does not then go to the thank you page, nor does any information get emailed to address specified.

          I have copied the snippet and chunk code according to the documents, which include the "[+validationmessage+]" in the "eFeedbackForm" chunk, but to no avail.

          Any pointers here are appreciated, I work with PHP, but not on an advanced level and would really love to get over this hurdle.

          Thanks,
          msflux.
            • 25307
            • 114 Posts
            This may be a bit too simple, but can hopefully get you started. The most basic type of validation available with eForm is validating whether or not a field is required. I rarely use anything other than this and maybe email. In the template (&tpl) chunk for your form layout, each input should be given an eForm attribute. The 0 or 1 at the end of the attribute is what determines whether the field is required or not. Once you get this, you should pick up on the rest of the templating and coding for validation works. Examples below of a required, required valid email address and a not required field.

            Required field...
            Name: <input name="name" size="40" type="text" eform="Name::1" />


            Required valid email address...
            Email Address: <input name="email" size="40" type="text" eform="EmailAddress:email:1" />


            Not required field...
            Street: <input name="street" size="40" type="text" eform="Street::0" />


            Hope that helps... =]
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Also make sure that the snippet call is uncached if the document it’s on is cached.
              [!eForm? ... !]
                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
                • 20508
                • 157 Posts
                Thank you for both your replies. I am definitely only in need of a simple validation, nothing advanced. I checked to make sure my code included validation for required fields, (ie: eform="Name::1") and it does, so I’m still stumped as to what I’m doing wrong. This may be one of those annoying moments where it’s something idiotically simple, I’m not sure. huh

                I’m including how I have everything set up in the manager. Below is my snippet and chunk names and below that is the code from the e"FeedbackForm" itself. If anyone spots anything out of sorts, I would greatly appreciate your feedback. I can then stop pulling my hair out...


                Snippet:
                The original "eForm" snippet

                Chunks:
                eFeedbackForm - A feedback form using the eForm snippet
                eFeedBackThanks - This is the thank you page the customer sees after sending an email via the Contact form on the Website
                eFormEmailFeedbackReport - This content is included in the body of the email sent to client from the contact form on the Website
                ContactForm - This is the contact form on the contact page (Chunk being called in on contact page document)

                The "eFeedbackForm" code:

                <p><span style="color:#900;">[+validationmessage+]</span></p>
                <form method="post" action="[~[*id*]~]">
                <input type="hidden" name="formid" value="feedbackForm" />

                <p><label accesskey="n" for="Name">Your Name</label>

                <input type="text" name="Name" maxlength="60" eForm="Your Name::1:Expected at least two words:#REGEX /\w+\b\w{2,}/i" /></p>




                <p><label accesskey="e" for="email">Your Email Address</label>

                <input type="text" name="email" size="40" maxlength="40" eForm="Your Email Address:email:1" /></p>




                <p><label accesskey="s" for="department">Subject</label>

                <select name="department">
                <option value="1">Website Feedback</option>
                <option value="2">Question Regarding a Product</option>
                <option value="3">General Email</option>
                </select></p>




                <p><label accesskey="c" for="comments">Comments</label>

                <textarea cols="40" rows="10" name="comments" eform="Comments:html:1"></textarea></p>







                <p><input type="submit" name="submit" value="Send Feedback"></p>
                </form>
                  • 30223
                  • 1,010 Posts
                  ContactForm - This is the contact form on the contact page (Chunk being called in on contact page document)
                  What do you mean by chunk being called on contact page??? Do you have an [!eForm &formid=`feedbackForm` ...more parameters... !] on your page at all?

                  Show us the source of your document perhaps.

                    • 20508
                    • 157 Posts
                    Quote from: TobyL at Oct 05, 2007, 11:15 AM

                    ContactForm - This is the contact form on the contact page (Chunk being called in on contact page document)
                    What do you mean by chunk being called on contact page??? Do you have an [!eForm &formid=`feedbackForm` ...more parameters... !] on your page at all?

                    Show us the source of your document perhaps.



                    Yes, I have the code you specified on my contact page. I also tried implementing it as a chunk trying to get it to work, but moved the code back to the document itself as follows:

                    [!eForm? &formid=`eFeedbackForm`
                    &to=`[email protected]`
                    &tpl=`eFeedBackForm` &report=`eFeedbackReport`
                    &thankyou=`eFeedbackThanks` &mailselector=`department`
                    &vericode=`1` &subject=`Web site feedback`!]
                      • 30223
                      • 1,010 Posts
                      It might help if you put all parameters on one line. MODx can not read snippets spanning more than one line.

                      [!eForm? &formid=`eFeedbackForm` &to=`[email protected]` &tpl=`eFeedBackForm` &report=`eFeedbackReport` &thankyou=`eFeedbackThanks` &mailselector=`department` &vericode=`1` &subject=`Web site feedback`!]