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

    I am very interested in this, but I am just starting to get my feet wet with modx revo and php. I would greatly appreciate it if someone would please explain how to implement this.

    I copied the code from Bruno17’s post and created the formit2resource and the resource2formit snippets, as well as a resource with the formit call and the code for the form. When I preview that resource, I can fill in the form. After I press the "Create Resource" button on the bottom of the form, the page goes blank and a new document does not seem to have been created anywhere.

    Thanks for any help.

      • 16633
      • 116 Posts
      In Bruno’s example code you specify the parent.
      So make sure you are entering in an id that exists for the resource to be created under.
        --
        Landon Poburan
        Web Designer and Developer

        http://www.categorycode.ca
        http://www.landonp.com
        • 24603
        • 7 Posts
        Hello again,

        I still haven’t been able to get this to work.

        Following landonpoburan’s suggestion, I’ve checked to make sure that I specify a parent id that actually exists. I have a container resource called "TestPages with a resource id of 48, and I am entering "48" (without quotes) in the "Parent" field of the form that Bruno’s code creates. After I finish the form, and click the "Create Resource" button, the page clears and nothing else ever happens. I’ve checked the error log, and no errors or warnings are being generated.

        I suspect that something fails in the &preHook, because it appears that the form is never processed; no email is generated and no resource is created. Just to check, I added a &redirectTo, and this is never processed either.

        Does anyone have any suggestions on what I’m missing? Thanks for the help.

        -Bob
          • 4172
          • 5,888 Posts
          I suspect that something fails in the &preHook, because it appears that the form is never processed; no email is generated and no resource is created. Just to check, I added a &redirectTo, and this is never processed either.

          did you remove the &preHook to check if it has todo with that?
          the preHook is only needed if you want to edit existing resources and has nothing todo with form-processing.

          whats your actual snippet-call?
          you can try to find out where something goes wrong, when you add a line with
          return true;
          at top off the script.
          if that works (sends the mail), you can move the line down and see when your page gets blank.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 10355
            • 44 Posts
            Dear Bruno17
            Add a simple example to your snipets resource editing and adding value to the TV option
              • 24603
              • 7 Posts
              Hello,

              I am still having trouble with this one. Here is the snippet call I am using: (with my email address removed)

              [[!FormIt?  
                  &hooks=`formit2resource,email`  
                  &emailTo=`[email protected]`  
                  &emailTpl=`myEmailChunk2`  
              ]]


              I have tried to strip the snippet call down to the essentials to try to find my problem, but maybe I have left out something important. My problem seems to be with the formit2resource snippet, as I never get to the email hook. (FYI, I have used formit to create a simple contact page, and that worked fine.)

              As has been previously suggested, I have ensured that the parent resource for the new document does exist, and if I add a

              return true;


              statement at the head of the formit2resource snippet, the email hook runs.

              Is there something within the formit2resource snippet that I am supposed to modify? I just can’t see what I’m missing.

              As always, thanks to the Modx community for the help.

              -Bob
                • 4172
                • 5,888 Posts
                did you try to move
                return true;

                some lines down to see on which line it stops to work?
                do you see errors in your error-log?
                do you have the latest formit-version?
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 10355
                  • 44 Posts
                  Hello,

                  help me how to add a TV in the form?
                  and how to edit a resource?
                    • 24603
                    • 7 Posts
                    Hello,

                    Thanks to Bruno17, I now have this working. All I needed was to upgrade formit.

                    Regards,
                    -Bob
                      • 4172
                      • 5,888 Posts
                      @G4:

                      for TV just add something like that to your form:

                      <label for="mytv">
                              My TV:
                              <span class="error">[[+fi.error.mytv]]</span>
                          </label>
                          <input id="mytv" name="mytv:required" type="text" value="[[+fi.mytv]]" />	
                      	<br/>


                      for editing resources use resource2formit as prehook and add all your fields and tvs to &resource2formitfields
                      Example:

                      [[!FormIt? &hooks=`spam,formit2resource,email` &preHooks=`resource2formit`
                      &resource2formitfields=`parent,pagetitle,mytv,content`&emailTpl=`myEmailChunk` &emailTo=`[email protected]`]]


                      and create a link to your formit2resource - page (let’s say it has the id 200) for example from a page whre you list your resources you want to edit with getResources.

                      in your getResources - tpl:
                      <a href="[[~200? &resId=`[[+id]]`]]">Edit resource</a>


                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!