We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36786 ☆ A M B ☆
    • 209 Posts
    Doesn't work sadly (I removed the extra parentheses on line 7), it still hangs on save.
      Ben Morrison
      Hacking templates to pieces since 2003
    • discuss.answer
      • 4172
      • 5,888 Posts
      switch ($modx->event->name) {
          case 'OnDocFormSave':
            
              $created_by = $resource->getTVValue('setCreatedBy');
                
              if (!empty($created_by) && $resource->get('createdby') != $created_by) {
                  $resource->set('createdby', $created_by);
                  $resource->save();
              }
          break;
      }
      [ed. note: Bruno17 last edited this post 12 years, 5 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36786 ☆ A M B ☆
        • 209 Posts
        Thanks Bruno, it certainly doesn't hang anymore but it doesn't change the createdby field. I'm using [[*createdby]] tag to check.
          Ben Morrison
          Hacking templates to pieces since 2003
          • 4172
          • 5,888 Posts
          This definitely should work. Just tested it.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 36786 ☆ A M B ☆
            • 209 Posts
            I checked all the settings, the plugin is set to fire on onDocFormSave, the cache was cleared after the change just to be sure. Could it have anything to do with the @EVAL binding I used to populate the original TV?

            @EVAL return $modx->runSnippet('Peoples',array('tpl'=>'peoplesTpl','outputSeparator'=>'||','active'=>'1'));


            peoplesTpl:
            [[+fullname]]==[[+id]]


            I know I am missing something.
              Ben Morrison
              Hacking templates to pieces since 2003
              • 4172
              • 5,888 Posts
              the TV - setup looks good
              setCreatedBy

              this is the correct TV - name?

              do you get the correct value with

              [[*setCreatedBy]]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 36786 ☆ A M B ☆
                • 209 Posts
                I get the right value from:

                [[*setCreatedBy]]


                Just not from:

                [[*createdby]]


                The name of the TV is correct.
                  Ben Morrison
                  Hacking templates to pieces since 2003
                  • 4172
                  • 5,888 Posts
                  does GridClassKey do something differently here, than a normal resource?
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 36786 ☆ A M B ☆
                    • 209 Posts
                    I have been using a resource outside of GridClassKey to prevent that from happening. It is just a standard resource.
                      Ben Morrison
                      Hacking templates to pieces since 2003
                      • 4172
                      • 5,888 Posts
                      case 'onDocFormSave':


                      should be

                      case 'OnDocFormSave':


                      corrected my posts above, too

                      also, because its only one system-event, you wouldn't need the system-event - switch
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!