Manual:HTMLForm Tutorial 3

Any kind of field can be generated by HTMLForm, field-specific options will be described here. Generic options (those any field can be assigned) are described on Tutorial 2.

Introduction
In $formDescriptor, there are two ways to declare a field type:

Class
First you can set the class attribute (do not mix with cssclass) 'class' => 'HTMLTextField'
 * HTMLTextField: A simple text field
 * HTMLFloatField: A simple text field with float (number) validation
 * HTMLIntField: A simple text field with integer validation
 * HTMLTextAreaField: An extended text field
 * HTMLSelectField: A dropdown menu
 * HTMLSelectOrOtherField: A dropdown menu with an 'other' option that toggles a simple text field on.
 * HTMLSelectAndOtherField: A dropdown menu and a simple text field (what for?)
 * HTMLMultiSelectField: List of checkboxes
 * HTMLRadioField: Radio buttons
 * HTMLCheckField: Single checkbox
 * HTMLCheckMatrix: 2D matrix of checkboxes
 * HTMLInfoField: Just text, no input
 * HTMLSubmitField: Additional submit button (HTMLForm always adds one anyway...)
 * HTMLHiddenField: Hidden field (data you need traveling, but not edited)

Type
Before in this tutorial, we used class, now we're going to use type. type provides a shortcut to class. Do not use both 'type' => 'text'
 * text = HTMLTextField
 * password = HTMLTextField
 * textarea = HTMLTextAreaField
 * select = HTMLSelectField
 * radio = HTMLRadioField
 * multiselect = HTMLMultiSelectField
 * check = HTMLCheckField
 * checkmatrix = HTMLCheckMatrix
 * int = HTMLIntField
 * float = HTMLFloatField
 * info = HTMLInfoField
 * selectorother = HTMLSelectOrOtherField
 * selectandother = HTMLSelectAndOtherField
 * submit = HTMLSubmitField
 * hidden = HTMLHiddenField


 * email = HTMLTextField (supposedly for html5 client-side validation, NO SERVER-SIDE VALIDATION HERE!)


 * toggle = HTMLCheckField simmilar to check, but through use of "invert"=>true default state can be set to checked
 * edittools = HTMLEditTools inserts system message, a parsed content of MediaWiki:Edittools

Goal
The following code builds this form:



text
A simple text field called 'text':

password
A text field displayed like password field called 'password':

float
A text field validated only by floating numbers called 'float':

int
A text field validated only by integers called 'int':

textarea
An extended text field called 'textarea':

select
A drop-down menu called 'select':

selectorother
A dropdown menu with an 'other' option that toggles a simple text field on called 'selectorother':

selectandother
A dropdown menu and a simple text field called 'selectandother':

multiselect
Checkboxes field called 'multiselect':

radio
Radio buttons field called 'radio':

check
A single checkbox field called 'mycheck':

checkmatrix
A 2D matrix of checkboxes called 'checkmatrix':

info
Just raw text string (no input at all) called 'info':

submit
A submit button called 'submit' (there's already one by default at the end of the form, this is an additional button):

hidden
An hidden text input called 'hidden':