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
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.
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
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.
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
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
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