Manual:Hooks/EditFormPreloadText

EditFormPreloadText
Available from version 1.7.0
Called when edit page for new article is shown
Define function:
public static function onEditFormPreloadText( &$text, &$title ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"EditFormPreloadText": "MediaWiki\\Extension\\MyExtension\\Hooks::onEditFormPreloadText"
	}
}
Called from: File(s): EditPage.php
Interface: EditFormPreloadTextHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:EditFormPreloadText extensions.

Details

edit
  • $text: text to prefill edit form with
  • $title: title of new page (Title Object)

Example

edit

To prefill page text when creating "A_New_Page" with "please enter text for A New Page"

$wgHooks['EditFormPreloadText'][] = array('prefill');


function prefill(&$textbox, &$title) {
    $title_str = $title->getText();
    $textbox = "please enter text for $title_str";
    return true;
}