OnDocFormRender
Last updated Apr 12th, 2019 | 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
$311 per month—let's make that $500!
Learn moreEvent: OnDocFormRender¶
Fires after a Resource editing form is loaded in the manager. Useful for inserting HTML into forms, and as of 2.4 for setting several default values on new resources
- Service: 1 - Parser Service Events
- Group: Documents
Event Parameters¶
Name | Description |
---|---|
mode | Either 'new' or 'upd', depending on the circumstance. |
resource | A reference to the modResource object. Since 2.4, this will contain an empty resource object when creating a new resource. Before 2.4 this would be null. |
id | The ID of the Resource. Will be 0 for new Resources. |
Setting Default Resource Values¶
As of Revolution 2.4.0, you can use a plugin OnDocFormRender for setting a value for one of the following fields:
- pagetitle
- longtitle
- description
- introtext
- content
- link_attributes
- alias
- menutitle
It is advised to only do this on new resources, as any values you set will override existing resource values.
Here is how you might use it:
$eventName = $modx->event->name;
switch($eventName) {
case 'OnDocFormRender':
if ($mode == modSystemEvent::MODE_NEW) {
//устанавливаем значения по умолчанию
$resource->set('pagetitle', 'Heading');
$resource->set('description', 'Description');
$resource->set('content', 'Content');
}
break;
}
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
$311 per month—let's make that $500!
Learn more