We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Don't thank me until it works. 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
      • 51020
      • 670 Posts
      Quote from: BobRay at Jun 14, 2017, 04:05 PM
      Don't thank me until it works. wink

      It works! Or course it does - you're 'BobRay'!! smiley
        • 3749
        • 24,544 Posts
        Thanks. wink

        Of the three, which solution did you use?
          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
          • 51020
          • 670 Posts
          The second one -

          
          public function process($value,array $params = array()) {
                  $options = array();
                  foreach($params as $key => $val) {
                      if (!empty($val)) {
                          $options[$key] = $val;
                      }
                  }
                  $mainOptions = array_merge(array('id' => $value), $options);
                  $properties = $this->tv->properties;
                  $properties = $properties === null? array() : $properties;
              return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
              }
          }
          


          Although I think from further advice it is probably worth migrating the forms to Formit as I didn't realise the Extra I am using is not really supported any more.
            • 3749
            • 24,544 Posts
            Did you try the third one? It's the simplest, and is likely to have the fewest side effects.
              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
              • 51020
              • 670 Posts
              I didn't. I will try just to satisfy curiosity though! wink
              My main aim is to migrate to formit I think.
                • 3749
                • 24,544 Posts
                Thanks. Let me know if it works and I'll try file an issue and/or a pull request at GitHub.
                  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
                  • 51020
                  • 670 Posts
                  Quote from: BobRay at Jun 13, 2017, 06:05 PM
                  This is the problem code:
                      public function process($value,array $params = array()) {
                          $options = array();
                          foreach($params as $key => $val) {
                              if (!empty($val)) {
                                  $options[$key] = $val;
                              }
                          }
                          $mainOptions = array_merge(array('id' => $value), $options);
                  	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                      }
                  }


                  Replacing the return line with this could possibly fix it, but see better fixes below:

                  return $this->modx->runSnippet('fmzForms', (array) array_merge($mainOptions, $this->tv->_properties));


                  Probably a better fix would be to change the function to this:

                      public function process($value,array $params = array()) {
                          $options = array();
                          foreach($params as $key => $val) {
                              if (!empty($val)) {
                                  $options[$key] = $val;
                              }
                          }
                          $mainOptions = array_merge(array('id' => $value), $options);
                          $properties = $this->tv->properties;
                          $properties = $properties === null? array() : $properties;
                  	return $this->modx->runSnippet('fmzForms', array_merge($mainOptions, $this->tv->_properties));
                      }
                  }



                  Another fix (the best if it works) would be to use the original code and change:

                  $this->tv->_properties


                  to

                  $this->tv->getProperties()



                  [Update] Did some quick testing, and I think the final solution above would solve things. If there are no properties, $tv->_properties is null, but $tv->getProperties() returns an empty array, which should satisfy runSnippet().

                  BTW, I think this may not be a PHP 7 problem, but rather a change in the error level settings when you switched. The code is a problem for any version of PHP with the current version of MODX, but a different error level may have hidden that.
                  Sorry bob - just coming back to this _ i'm trying your third option to see if it works, but I cannot find the line of code which contains:

                  Another fix (the best if it works) would be to use the original code and change:

                  $this->tv->_properties


                  to

                  $this->tv->getProperties()


                  Which file is this in?

                  Thanks
                  Andy
                    • 3749
                    • 24,544 Posts
                    Sorry, I never clarified that (and I had to go find it again myself wink ). It's this FormZ processor class:

                    core/components/formz/processors/mgr/tv/output/formz.class.php
                      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
                      • 51020
                      • 670 Posts
                      Quote from: BobRay at Jun 26, 2017, 06:16 PM
                      Sorry, I never clarified that (and I had to go find it again myself wink ). It's this FormZ processor class:

                      core/components/formz/processors/mgr/tv/output/formz.class.php

                      Hi Bob - I recently replied saying that it didn't work - but I made the ame3nds to the wrong file - I've just tried again, and it worked perfectly!!! Nice one.
                      Sorry it too so long for me to test this - just been very busy.

                      Glad to see it worked though! Will you suggest the update for the plugin?

                      Thanks
                      Andy