We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    What is the difference between OnDocFormSave and OnBeforeDocFormSave?

    And I dont want to know that OnDocFormSave is an event that triggers when
    a document is saved and OnBeforeDocFormSave is an event that triggers before
    the document is saved.

    I would like to know what happens between the two events and when is good to
    use one and when is good to use the other one...

    (the same would be nice to know between OnTVFormSave and OnBeforeTVFormSave)

    Thanks in advance...
      Website: www.mercologia.com
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
      • 5340
      • 1,624 Posts
      I guess it depend on what you need to do.

      Eg:
      Use OnBeforeDocFormSave if you want to alter the information before you save it to the db(it’s up to you what you want to do)
      Use OnDocFormSave when you want to notify a user that a document was saved.

        • 4971
        • 964 Posts
        So if I have a TV that is modified by the user when editing a document (not when creating)
        I can use OnTVFormSave or OnBeforeTVFormSave or OnBeforeDocFormSave to do some processing
        of the edited values? before the doc is saved of course...
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 3749
          • 24,544 Posts
          OnBeforeDocFormSave fires before any TVs or resource groups are saved, so it might be all you’d need depending on what you are trying to do.

          OnDocFormSave comes after they are saved.


          I’m pretty sure the two TV events will only fire if you are creating or editing a single TV in the Create/Edit TV panel. I don’t think they will fire at all when you save a document after modifying its TVs.
            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
            • 4971
            • 964 Posts
            Thanks a lot Bob for clarifying these concepts,
            now that you mention it, it makes sense what you indicate regarding the
            TV events.

            Do you know of any hidden documentation gem regarding events that we could read?
              Website: www.mercologia.com
              MODX Revo Tutorials:  www.modxperience.com

              MODX Professional Partner
              • 20413
              • 2,877 Posts
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 4971
                • 964 Posts
                THanks MRhaw, I have read the wiki one, kinda weaky if you ask me...
                I will read Susans one, I am guessing it complements her Execution Order entry
                in the wiki...
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 38290
                  • 712 Posts
                  I have at least somewhat similar confusion. I'm noticing that when using OnDocFormSave and checking the value of a TV $resource->getTVValue() is returning the value it was, not the value it will be after the document has saved.

                  I've got a text field where an address is entered, and a hitAPI checkbox that if ticked hits a location API with that address and saves lat&long to hidden TVs. Problem is I have to tick the box the way i want it, then save the resource (to set that value) to get expected results.
                    jpdevries