We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    That is certainly nice to know!
      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
      • 29774
      • 386 Posts
      My function looks like this:
      # called on eFormOnValidate
      function checkPassword(&$fields, &$vMsg, &$rMsg, &$rClass) {
      	global $modx;
      	if($fields['password'] != $fields['password-confirm']){
      		$vMsg['password'] = "Password » Passwords must match";
      		$rClass['password'] .= $rClass['password'] ? ' ' . 'required' : 'required'; // hardcode css class name :(
      	}
      	return true;
      }
      


      print_r($modx->event) outputs this:
      SystemEvent Object ( [name] => OnParseDocument [_propagate] => 1 [_output] => [activated] => [activePlugin] => PHx ) 1
      


      ( print_r($modx->event->params) output nothing )

      So I think the PHx plugin may be preventing the parameters being stored in the event object?

      EDIT: just tried disabling PHx and print_r($modx->event) outputs this:
      `*]
      SystemEvent Object ( [name] => [_propagate] => 1 [_output] => [activated] => [activePlugin] => ) 1
      


      .. and print_r($modx->event->params) now outputs:

      `*]
      1
      


      Now I’m confused!
        Snippets: GoogleMap | FileDetails | Related Plugin: SSL
        • 12379
        • 460 Posts
        Some typos to watch in TobyL’s improvement above:

        Missing "$"
        function reqFields(&$fields, &$vMsg, &$rMsg, &$rClass)

        Delete "!":
        if(!$fields[’why’]){
          Mostly harmless.
          • 30223
          • 1,010 Posts
          Thanks for catching the typo but I’m not entirely certain why you would remove the negation (!) in if(!$fields[’why’]){. The whole point is to check if there’s a value for $fields[’why’] and if not prepare a form error.
            • 3749
            • 24,544 Posts
            Try passing $modx as an argument to checkPassword rather than accessing it as a global. I’ve found that globals aren’t always reliable in nested/included functions.
              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
              • 12379
              • 460 Posts
              Thanks for catching the typo but I’m not entirely certain why you would remove the negation (!) in if(!$fields[’why’]){. The whole point is to check if there’s a value for $fields[’why’] and if not prepare a form error.

              Neither am I but it didn’t work until I removed it! Perhaps it was because I was using it differently:

              http://modxcms.com/forums/index.php/topic,35318.0.html
                Mostly harmless.