We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    Well...that did not work. Got some kind of Parse Error when I tried to view the resource in my browser.

    Tried else return;

    also else return();

    and just plain return ();

    Doing this on just the top FormIt Snippet, though many of the add ons have multiple snippets associated with them.

    ??? [ed. note: mmcgee last edited this post 9 years, 9 months ago.]
      • 22840
      • 1,572 Posts
      I'm not a backend developer but I'm sure those else and return should have curly brackets round them so try:

      require_once $modx->getOption('formit.core_path',null,$modx->getOption('core_path',null,MODX_CORE_PATH).'components/formit/').'model/formit/formit.class.php';
      $fi = new FormIt($modx,$scriptProperties);
      $fi->initialize($modx->context->get('key'));
      $fi->loadRequest();
      
      $fields = $fi->request->prepare();
      return $fi->request->handle($fields);
                  }
      else
          return;
        • 19872
        • 1,078 Posts
        That didn't work. Unless the error is generated on my contact page with FormIt because I have not made the edit to every snippet?

        Parse error: syntax error, unexpected '}' in /home/mysite/public_html/core/cache/includes/elements/modsnippet/2.include.cache.php on line 37
          • 22840
          • 1,572 Posts
          Quote from: mmcgee at Jul 18, 2014, 06:28 PM
          That didn't work. Unless the error is generated on my contact page with FormIt because I have not made the edit to every snippet?

          Parse error: syntax error, unexpected '}' in /home/mysite/public_html/core/cache/includes/elements/modsnippet/2.include.cache.php on line 37

          Sorry, update the post above, try that, if not you may need to wait for someone else
            • 19872
            • 1,078 Posts
            Thanks for helping. I hope the developers will chime in soon.
            • "else" only goes with "if" conditionals.
              if(some-condition) {
                  do-something;
              } else {
                  do-something-else;
              }
              
              
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 19872
                • 1,078 Posts
                Quote from: sottwell at Jul 19, 2014, 04:01 AM
                "else" only goes with "if" conditionals.
                if(some-condition) {
                    do-something;
                } else {
                    do-something-else;
                }
                
                

                Thanks Susan:
                With my level of php skill, I'm not comfortable making changes to Extras for fear that those changes might create other, more serious problems. FormIt alone has multiple snippets. Does each snippet get a return; inserted at the end? Won't that mess with how they all work together?
                • No. Each one is treated as a function, so each one should end with a return statement, even if it's just an empty "return;" statement.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 19872
                    • 1,078 Posts
                    I'll try adding return; to each snippet and see if it gets rid of the MODx errors and or creates other issues. It would be helpful if the error could indicate which snippet is causing the problem. The error messages are kind of vague.

                    • That's because they aren't really errors and have little to do with the actual plugin, they're return values from the functions that are invoked by the events, which in turn include your plugin code. Any plugin using that event that doesn't have an empty return value will have the same effect. Any return from a plugin's code goes to the error log, and if there is no return statement then it falls through to the parent function's return value.

                      http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins#Plugins-CustomValidation
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org