Manual:Hooks/EditPage::showEditForm:initial

From MediaWiki.org
Jump to: navigation, search
EditPage::showEditForm:initial
Available from version 1.6.0
Called just before the preview and edit form are rendered

*Define function:
function fnMyHook( $editPage ) { ... }

*Attach hook:
$wgHooks['EditPage::showEditForm:initial'][] = 'MyExtensionHooks::someExample';
Called from: EditPage.php

*For more information about attaching hooks, see Manual:Hooks.
*For examples of extensions using this hook, see Category:EditPage::showEditForm:initial extensions.


[edit] Details

  • $editPage: the current EditPage object.

[edit] Notes

You can do something like:

if( $editPage->formtype == 'preview' ) {
    // performing a preview.
}

to only take action on certain types of edits.

[edit] Inject HTML

There are many locations within EditPage::showEditForm:initial that allow a user to inject HTML. These hook locations are represented by member variables of the editPage object.

$editPage->editFormPageTop
$editPage->editFormTextTop
$editPage->editFormTextBeforeContent
$editPage->editFormTextAfterWarn
$editPage->editFormTextAfterTools
$editPage->editFormTextBottom

To inject your HTML, append your HTML to one of the aforementioned member variables, e.g.

$editPage->editFormPageTop .= "<span>Hello World!</span>";

Some hook locations are inside forms; some not. Those inside the form allow you to inject HTML form elements.

  • Inside form
    • editFormTextBeforeContent
    • editFormTextAfterWarn
    • editFormTextAfterTools
    • editFormTextBottom
  • Outside form
    • editFormPageTop
    • editFormTextTop

Normally, we use EditPage::showEditForm:fields for form elements, but there may be some circumstances for which it is necessary to use the aforementioned hook locations.

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox