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

    I’m looking to find out the correct ’modx’ way to go about displaying and processing a form which will:
    * take a number of text/textarea fields
    * put the data into a database table with corresponding columns for each field
    * upload an image in the process.

    Should I create a snippet, which uses some external code, one function of which generates the form, and another function of which processes the form?

    If I use a snippet to call up the form, how do I specify the action of the form. Should I create a new page which calls up the function to process the form, and use this page as the action of the form.

    Just doesn’t seem very modxy to me...

    Just looking for some guidelines smiley

    thanks
    subd
      • 5340
      • 1,624 Posts
      For generating the Form use eForm snippet. Very easy to use

      You can send email with it;but instead of sending the info by email you could use modx API to insert data into a new table.
        • 6726
        • 7,075 Posts
        Or the best starting point at the moment is to use the eForm2db snippet but you’ll have to work a bit to set things up...
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 5340
          • 1,624 Posts
          nice, I will have a look
            • 7455
            • 2,204 Posts
            I made a snippet (read eform plugin) that does that bassed on the eform2db
            this my call(s)
            [!eForm2db!]
            [!eForm? &eFormOnBeforeMailSent=`eform2db` &formid=`fotoupload_form` &to=`[email protected]` &report=`fotoupload_report` &tpl=`fotoupload_form` &subject=`Nieuwe foto upload van [+naam+]` &thankyou=`fotouploadbedankt` &language=`nederlands` &gotoid=`5`!]
            

            the code and class I used is in the zip
            I also made a snippet that gets the values from the db (a bit like Ditto) with placeholders and a chunk
              follow me on twitter: @dimmy01
              • 6726
              • 7,075 Posts
              Great Dimmy that’s just what I needed ! I am downloading and will report when I have toyed with it smiley
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l'outil id
                • 28779
                • 25 Posts
                thanks for the replies. And say if one of the fields was a file to upload an image - any ideas how I might do this?

                Thanks
                  • 7231
                  • 4,205 Posts
                  Dimmy; Thanks for posting this. I am very interested in seeing how this works but I could not open the attachment. It decompresses the folders without the files. Is anyone else having this problem?

                  Extracting from /Desktop/eform2db_image.rar

                  Creating /Desktop/assets OK
                  Creating /Desktop/assets/snippets OK
                  Creating /Desktop/assets/snippets/fotowedstrijd OK
                  Extracting /Desktop/assets/snippets/fotowedstrijd/snapshot.class.php  67%
                  assets/snippets/fotowedstrijd/snapshot.class.php - CRC failed
                  Unexpected end of archive
                  Total errors: 2

                  subd: this is what the code submited by Dimmy is intended to handle. In theory I think you would use eForm and run a function to handle the image upload. eForm allows you to work with the form data in various stages during the processing (after its captured but before it is processed, or after validation but before sending). There are some examples in the documentation located with the snippet code in /assets/shippets/eform/docs/
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 28779
                    • 25 Posts
                    Dimmy; Thanks for posting this. I am very interested in seeing how this works but I could not open the attachment. It decompresses the folders without the files. Is anyone else having this problem?

                    Yep, I’m getting the same problem. Dimmy, please could you post the archive again? Thanks.
                      • 7455
                      • 2,204 Posts
                      OK i changed it it the first reply i made to a ZIP maybe thats better.

                      Its commented in dutch but I could translate it if its not clear.
                      be sure to create a database table with the right cells

                      Dimmy
                        follow me on twitter: @dimmy01