Manual:HTMLForm Tutorial

HTMLForm is a powerful and easy helper to build forms within MediaWiki. This tutorial will help SpecialPages developers to get started with HTMLForm.

(HTMLForm being a front-end helper, it's assumed that you are developing a front-end extension. ie: a Special Page)

The rest of this page is about the basics of creating a generic SpecialPage Extension called MyForm. This is not directly related to this tutorial, but I guess it won't hurt to show how the extension should look like. At the bottom of the page the Special:MyForm displays "Hello World".

Skip the newbie part and directly go to the HTMLForm Stuff

Otherwise, let's get started...

Files Environment
HTMLForm Classes are at /mediawiki/includes/HTMLForm.php Code is pretty clean and well-documented enough, that should make MW Hackers happy.

Your SpecialPage is in an extension called MyForm. You'll call it by accessing: Special:MyForm

Your SpecialPage's front-end code can be at: /mediawiki/extensions/MyForm/MyForm_body.php This previous file enclosing both View/Controller, the Model (main file of your extension) can be at: /mediawiki/extensions/MyForm/MyForm.php The i18n file can be at: /mediawiki/extensions/MyForm/MyForm.i18n.php Then .hooks, .alias...

LocalSettings.php
Do not forget to install your extension by adding: require_once( "$IP/extensions/MyForm/MyForm.php" );

MyForm.i18n.php
This file will hold all the messages used within your form. Be careful with the messages' IDs, they will be specified later in this tutorial.

MyForm_body.php
Finally, the file that interests us the most

NEXT PAGE OF THE TUTORIAL