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

    I have created a 'plain old HTML' CMP as per this post: http://rtfm.modx.com/display/revolution20/Custom+Manager+Pages

    My CMP has a very simple form (post method) that I am using to collect data entered by my colleagues that will be sent to clients via the modMail function. It works well right now however I'm limited in the operations regarding looking up past submitted forms (emails). So basically, unless they bcc themselves in the original form, there are no traces of the data since I'm not submitting it to the database for storing.

    So my question is this: How do I submit the data on the form to the database? I have been reading up on the fact that it will be a custom table however I'm not locating the code to allow the form to communicate with the database.

    MODX version: 2.2.6-pl

    Please let me know if you need further information or code from my form. Thanks in advance and happy coding!


    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      One way might be to use FormIt2DB to process the form.

      The more "official" method would be to have create and update processors and post the form data to them. In the processors, you'd use xPDO to alter the database (right after the email is sent).
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 44002
        • 3 Posts
        Quote from: BobRay at Jun 03, 2013, 10:35 PM
        One way might be to use FormIt2DB to process the form.

        The more "official" method would be to have create and update processors and post the form data to them. In the processors, you'd use xPDO to alter the database (right after the email is sent).

        Thank you for your quick reply. I had read earlier about FormIt2DB and agree this might be easiest way to handle it.

        I will look into the create and update processors...I should have realized they played a role in it smiley Thanks again for the assistance!
          • 3749
          • 24,544 Posts
          In a typical CMP, the menu item launches an index.php file. The index.php file launches a controller that creates the display and handles requests (e.g., mouse clicks in the form).

          The request handler routes the request to a connector file which calls the appropriate processor. TBH, I'm not sure of the details on how the return value from the processor is handled. I think it comes back to the controller vie the connector.

          In the usual JS setup, the mouse clicks on the form trigger Ajax requests to the request handler, but I don't think there's any reason that a standard HTML form couldn't do the same thing.

          Someday, when I have time, I'm going to create a complete CMP with no JS at all, just to figure it all out.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 44002
            • 3 Posts
            Quote from: BobRay at Jun 03, 2013, 10:58 PM
            In a typical CMP, the menu item launches an index.php file. The index.php file launches a controller that creates the display and handles requests (e.g., mouse clicks in the form).

            The request handler routes the request to a connector file which calls the appropriate processor. TBH, I'm not sure of the details on how the return value from the processor is handled. I think it comes back to the controller vie the connector.

            In the usual JS setup, the mouse clicks on the form trigger Ajax requests to the request handler, but I don't think there's any reason that a standard HTML form couldn't do the same thing.

            Someday, when I have time, I'm going to create a complete CMP with no JS at all, just to figure it all out.

            Awesome information to have, Bob. This helps me figure the best way to approach my CMP because we have many CMPs that are using the approach listed above; however, I was confused with the exact process of the information. I'll be investigating this with your explanation in mind. Thank you. You've been more helpful than you may realize! Cheers.
              • 3749
              • 24,544 Posts
              I'm glad I could help. smiley

              The Batcher extra is a good example of the older, non-class-based CMP components and my Orphans extra might be helpful as well (though its main processor is not a typical processor).

              For the new class-based ones (which I really like), see Mark Hamstra's ClientConfig or HandyMan, and splittingred's Rampart.

              One tool I can't live without in trying to learn from someone else's code is JetBrains PhpStorm. I create a MODX install locally and tell PhpStorm to create a project based on the MODX root directory. Then I install any packages I want to study (and my own extras).

              The killer feature for exploring class code is that you can put the cursor on any class name and press Ctrl-B and you'll instantly jump to the class itself, no matter where it is in the project. When you see that a class "extends" another class, you can jump to the parent class (and then its parent and its parent etc.) Ctrl-Alt-Left-Arrow works like a "back" button in this process. This is invaluable in MODX, where classes are often nested three or four deep and many of them contain almost no code.

              Another valuable item is Chrome's Developer Tools, which lets you see the requests being made and the responses/data returned from them in real time.

              By the time you figure everything out, you may decide you want to use ExtJS for the CMP. That's what happened to me. wink It was quicker to just base parts of my code on other components than to work up my own.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 4172
                • 5,888 Posts
                A quick way to create CMPs (from simple to complex) is MIGXdb.
                See the MIGXdb - doodles - tutorial for a start.

                There is also migxFormbuilder, if you want to use plain html and formit to do the stuff.
                https://github.com/Bruno17/migxFormbuilder

                It has a CMP where you can define your forms and formit-settings.
                A snippet which creates the form and handles the formit-calls.
                And a CMP to view the submitted forms.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3749
                  • 24,544 Posts
                  Sorry Bruno. I don't know why I always forget about MIGXdb. I should have mentioned that in my post. wink
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting