Jump to main content Jump to doc navigation

Event: OnDocFormRender

Fires after a Resource editing form is loaded in the Manager. Use it to insert HTML straight into the form.

  • Service: 1 - Parser Service Events
  • Group: Resources

Event Parameters

Name Description
mode Either new or upd (modSystemEvent::MODE_NEW / MODE_UPD).
id The ID of the Resource. This will be 0 for new Resources.
resource A reference to the modResource object. Since 2.4 an empty object for new Resources; before 2.4 null.

Setting Default Resource Values

Since Revolution 2.4.0, a plugin on OnDocFormRender can set a value for one of the following fields:

  • pagetitle
  • longtitle
  • description
  • introtext
  • content
  • link_attributes
  • alias
  • menutitle

Do this only on new Resources: on existing ones, the values you set will override the current ones.

$eventName = $modx->event->name;
switch($eventName) {
    case 'OnDocFormRender':
        if ($mode == modSystemEvent::MODE_NEW) {
            // set default values
            $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

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more