We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    This is an auto-generated support/comment thread for MakeForm.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    A helper class for building dynamic forms that are easily defined via simple PHP arrays and rendered via Chunks.
      • 11214
      • 225 Posts
      Hello OpenGeek,

      I’m a very big newbie in Modx (and English speeking) and I have install your MakeForm Snippet, with all of your instructions.

      So in the front on my new document, I see that it seems possible to create a new table with this makeform and after ?

      Nothing Happens...can you explain to a newbie how it works ? (sorry for my very bad english...)

      Thanks
        Verum Index sui et falsi
        • 686
        • 24 Posts
        Hi.

        Quick question.. is there any validation processing in MakeForm?

          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: aicos at Mar 13, 2007, 11:15 AM

          Hi.

          Quick question.. is there any validation processing in MakeForm?
          At the moment, no, there is nothing built into MakeForm to do the validation, but this is definitely part of the next generation MakeForm that I am developing as part of xPDO. However, you can easily add JS and or server-side validation in your snippets that use the current version of MakeForm. I just had too many very complex validation requirements when I first developed this and wanted that to be separate from the actual form rendering and processing engine for flexibility...
            • 19328
            • 433 Posts
            Hi, I hope it’s ok I reply on this post, not sure if I should start a new topic or not, but I got a question about MakeForm.

            First of all, MakeForm is very handy! I’ve got it working almost perfectly. There is just a small thing: when someone enters a value that’s already in the database and has to be unique, I get the following error:

            « MODx Parse Error »
            MODx encountered the following error while attempting to parse the requested resource:
            « Execution of a query to the database failed - Duplicate entry '9477' for key 2 »
                  SQL: INSERT INTO actiecodes_overzicht (actiecode,naam,prijs_id,toegevoegd) VALUES('9477','test',1,'2009-05-03 13:53:44') 


            I want to create my own error message so that if this happens the user can go back and correct his mistake. I just don’t know how I should do this. Probably somewhere in the makeForm class?



              • 22303 MODX Staff
              • 10,725 Posts
              michelle84:

              Generally, I try to look up a database record by any unique keys before creating a new one on such forms. You should be able to do this before you even call MakeForm, and either return or set a placeholder to present an error message and perhaps re-render the form with the user supplied values.
                • 19328
                • 433 Posts
                Thanks OpenGeek!
                Maybe I’m doing this all wrong, but how can I lookup a database record before I know what unique key the user will type into the input field?

                The situation is as follows: my client wants to have a database in which he can put unique codes and accompanying descriptions. Users can enter a code they have gotten from my client and see if they have won a prize. So my client has to enter those codes in the database himself. he clicks on a ’add code’ button and a popup with a blank MakeForm opens. He types in a code and a description. There is a chance he’ll accidently type a code that already exists in the database, which leads to the error I spoke of in my first post.

                What I’m looking for is the place in the code where this error would be thrown, so I can put my own custom error message in there...

                I hope I’m not asking really stupid questions here smiley
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: michelle84 at May 04, 2009, 02:39 PM

                  Maybe I’m doing this all wrong, but how can I lookup a database record before I know what unique key the user will type into the input field?
                  On the POST action in your script logic, you simply query the database for the record with the unique key the user has provided in the $_POST var, and if it exists, you generate an error message and, if applicable, re-render the form with the rest of the user supplied values from the $_POST.