We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • You might try integrating the following very nice client-side validation. This doesn’t address what should be done on the server side, but it’s a great start:

    http://dhtmlgoodies.com/scripts/dhtml-form-validation/dhtml-form-validation.html
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 20765
      • 90 Posts
      myfriendscallmebill Reply #22, 17 years, 7 months ago
      Great lead Ryan. Thanks!
        • 30694
        • 46 Posts
        Question:

        I would like to create a ’Refer this page to a friend’ form with fields where a person could enter email addresses of their friends are included. Is this possible with FormProcessor?
          • 8164
          • 51 Posts
          My rudimentary (at best) MySQL skills are failing me utterly. Here’s what I want to do: Members of the public fill out a foster parent application form. The information is mailed to appropriate managers and written to the database. FormProcessor has handled this without a hitch!!

          But, I want certain managers of the foster parent program to be able to log into a password protected page to view the current applictions. MODx handles the password protection fine, no problem there. It’s the displaying of the records I’m struggling with.

          The FormProcessor data is stored in a table named "modx_submission_data" and a field named "values." I want to control the display of the data inside the "values" field. For example to let the foster program managers search/sort the list by month of application, number or gender of children they wish to care for, current household size, etc. These are all values that are filled in on the form.

          The problem is, I haven’t been able to construct a query that displays anything except the entire contents of the "values" field in a vertical stack. I’m sure it’s just my stupidity, but I can’t seem to grab the data in a way I can manipulate it beyond the level of the "values" field. (In other words, I can’t figure out a way to query any deeper than db/table/field...and the FormProcessor data is stored a level deeper than that.)

          Can anyone point me in the right direction? I’m out of ideas!

          Thanks for any help...I really appreciate it!

          Duane

          • You mean that all the POST values from the form are dumped into one field in the database table? Basically useless. Each form field should be perfectly mirrored in your database table, possibly even more tables if you will have a lot of records and want to optimize your database queries.
              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
            • Ok, I retract my previous statement; after looking at how FormProcessor works. It uses a name->value structure, it actually uses three fields.

              First, it loads the "submissions" table with some data about that form submission. It then takes the insert_id from that, and uses it to identify this particular form submission.

              Now it enters the insert_id, the name of the field, and the value of the field for each field in the form, into the "values" table.

              So your query to get the information by using WHERE and GROUP BY clauses. It’s a little deep for me right now, but perhaps one of the SQL gurus are more familiar with how to query this kind of data organization.

                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
                • 8164
                • 51 Posts
                Thanks much for the input Susan!

                I’ve tried to construct a query using the GROUP BY with no luck (I didn’t figure I’d find enough MySQL knowledge to form a proper query.)

                Does anybody have any suggestions with how to display the data stored in the "values" field? I’m flatly out of ideas after about 10 hours of trial and error.

                Thanks,
                Duane
                • Hi Duane,

                  Now, if you have mySQL 4.1+, then this may not be too bad ... bearing in mind I haven’t used FormProcessor so I’m going on my interpretation of the description you’ve given above.

                  If I understand the problem correctly, then you have a table with at least three fields (form ID, field, value) and you need to transpose the name field into a column so you can sort on each of the fields.

                  In this case, here is an example query that illustrates one way in which you can do the transposition (with some made-up dummy values):
                  SELECT id,
                  group_concat( if( field = 'month', value, NULL ) ) AS Month,
                  group_concat( if( field = 'number of children', value, NULL ) ) AS NumberOfChildren
                  FROM `submissions`
                  GROUP BY id
                  ORDER BY NumberOfChildren;
                  

                  Essentially, the ’group_concat’ statements does all the work in transposing the values, the IF statement either returns the value if it’s available or a null if it’s not, and the ’AS ...’ bit is the name of the column you wish to create. You could add as many of these as you have possible field names (I don’t know how fast performance degrades doing this type of manipulation but it’s something to watch for). To sort the values, you just need to change the ORDER BY clause as required.

                  (something to watch out for is that mySQL could turn the values into BLOBs if the query reaches a certain length, so if you’re using phpMyAdmin you will need to export the data to visually see the values being returned in the query - the values will display fine through MODx as well)

                  Obviously, if you’re not running mySQL 4.1+, then it’s back to drawing board undecided
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 5980
                    • 1 Posts
                    Hi,

                    Can anybody tell me how I get the form to submit if I have a required checkbox in the form? I mean my form worked fine without the required checkbox. Do I need to declare another constant in the snippet and use a different class for the checkbox?
                    Any examples out there, using checkboxes (e.g checked to confirm you agree with/accept a certain condition?

                    Thanks

                    Jim Cricket,
                    New Zealand
                      • 2896
                      • 70 Posts
                      Quote from: web_designer at Aug 29, 2006, 08:10 PM

                      Also is there a way to setup CC in the form?

                      How can this be achieved with Formprocessor?

                      I simply want the e-mail also sent to the [+Email-value+] address of the person who fills in the form.

                      thx