OnDocFormSave
Last updated Apr 30th, 2024 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$290 per month—let's make that $500!
Learn moreEvent: OnDocFormSave¶
Fires after a Resource is saved in the manager via the editing form.
- Service: 1 - Parser Service Events
- Group: Documents
TVs are best Modified Here If you need to modify TV values, it's best to modify them here and not during OnBeforeDocFormSave.
Unlike OnBeforeDocFormSave, this event does not support the $modx->event->output() method.
Event Parameters¶
Name | Description |
---|---|
mode | Either 'new' or 'upd', depending on the circumstances. |
resource | A reference to the modResource object. |
id | The ID of the Resource (even for new resources) |
Examples¶
To do something with the page ID (e.g. to update a related custom table), you can read this out of the $resource object (even if you are creating a new resource):
Anything you return from this event will be written to the logs, e.g.
Will result in a log message like the following:
Calculating a TV Value¶
Such a plugin will display an array of the saved resource in the "Error log":
Such a plugin will set the value of the TV price of the current resource equal to 128, in case of an error an entry will be added to the "Error log":
It doesn't matter if the price field is filled in before saving or not. The plugin will write 128.
Saving Happens Automatically
No need to run the $resource->save()
method as that happens automatically.
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$290 per month—let's make that $500!
Learn more