We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6425
    • 23 Posts
    How do you go about creating custom forms that submit information on a form in the content area to a php script that does certain tasks. Is there anything special that I will have to do in ModX for this to work or are there any things that ModX won’t allow me to do? I am used to making forms that generate an email or submit/request database information with the following general characteristics <form onsubmit() action=script.php method=post>.
    • Take a look at the contact form that ships with the demo site content. There are no real limitations in MODx.

      Forms are handled in snippets, and can use chunks for formatting.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 6425
        • 23 Posts
        I have figured out how to do a basic email form. Will working with databases work the same way? If I want to pull information from a database and display it in the form (such as in a dropdown box) will the dbconnect() function go in the snippet?
        • Quote from: danderson at May 30, 2006, 08:27 PM

          I have figured out how to do a basic email form. Will working with databases work the same way? If I want to pull information from a database and display it in the form (such as in a dropdown box) will the dbconnect() function go in the snippet?

          It could, though that is actually a deprecated method (Ryan was more pointing out the email portion of the component, and not the db connection aspects). The DBAPI is what you’ll want to use and many of the latest snippets take advantage of this. I recommend taking a look at how other snippets are using this to get an idea of how best to approach this for any given requirement.

          Or you could use/start with any of the number of form snippets and/or classes that have been posted here in the forums. For instance, I created MakeForm to help with building and processing forms, but again, this is just one person’s approach to using MODx for this purpose. A quick search on many of these terms turns up quite a few results (just make sure you search from the actual SMF search page -- sometimes the searches from the search bar on the forum pages doesn’t seem to work properly).

          Finally, and I introduce this not to confuse you as you are just learning about MODx, but more to prepare you for what is coming in the near future in this area, I am also working on an ultra-light-weight object-relational bridge that will be driving the core of MODx 1.0. This new object / database layer will allow developers to create instant OO API’s based on a data model, easy porting (and optimization) of MODx to new database platforms, easy processing of forms based on objects and their related objects as described in the model, database platform agnostic data imports/exports, automatic table creation and alteration based on the model and any changes to it, full reverse and forward-engineering of databases/classes, and even the ability for MODx to take full advantage of the new standard DB layer in PHP 5.1+, PDO. Anyway, enough tantalizing and teasing for now...back to work on it for me...but I will be releasing a preview of this new object relational bridge in the very near future, so stay-tuned.

          Until then, cheers...

          8)