MediaWiki master
MediaWiki\HTMLForm\HTMLForm Class Reference

Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusable manner. More...

Inherits MediaWiki\Context\ContextSource.

Inherited by MediaWiki\HTMLForm\CodexHTMLForm, MediaWiki\HTMLForm\OOUIHTMLForm, and MediaWiki\Specials\Forms\UploadForm.

Collaboration diagram for MediaWiki\HTMLForm\HTMLForm:

Public Member Functions

 __construct ( $descriptor, IContextSource $context, $messagePrefix='')
 Build a new HTMLForm from an array of field attributes.
 
 addButton ( $data)
 Add a button to the form.
 
 addFields ( $descriptor)
 Add fields to the form.
 
 addFooterHtml ( $html, $section=null)
 Add footer HTML, inside the form.
 
 addHeaderHtml ( $html, $section=null)
 Add HTML to the header, inside the form.
 
 addHiddenField ( $name, $value, array $attribs=[])
 Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::getVal)
 
 addHiddenFields (array $fields)
 Add an array of hidden fields to the output Array values are discarded for security reasons (per WebRequest::getVal)
 
 addPostHtml ( $html)
 Add HTML to the end of the display.
 
 addPreHtml ( $html)
 Add HTML to introductory message.
 
 displayForm ( $submitResult)
 Display the form (sending to the context's OutputPage object), with an appropriate error message or stack of messages, and any validation errors, etc.
 
 displaySection ( $fields, $sectionName='', $fieldsetIDPrefix='', &$hasUserVisibleFields=false)
 
 filterDataForSubmit ( $data)
 Overload this if you want to apply special filtration routines to the form as a whole, after it's submitted but before it's processed.
 
 formatErrors ( $errors)
 Format a stack of error messages into a single HTML string.
 
 getAction ()
 Get the value for the action attribute of the form.
 
 getBody ()
 Get the whole body of the form.
 
 getButtons ()
 Get the submit and (potentially) reset buttons.
 
 getDisplayFormat ()
 Getter for displayFormat.
 
 getErrorsOrWarnings ( $elements, $elementsType)
 Returns a formatted list of errors or warnings from the given elements.
 
 getField ( $fieldname)
 
 getFooterHtml ( $section=null)
 Get footer HTML.
 
 getHeaderHtml ( $section=null)
 Get header HTML.
 
 getHiddenFields ()
 Get the hidden fields that should go inside the form.
 
 getHTML ( $submitResult)
 Returns the raw HTML generated by the form.
 
 getLegend ( $key)
 Get a string to go in the "<legend>" of a section fieldset.
 
 getMethod ()
 
 getPostHtml ()
 Get HTML at the end of the display.
 
 getPreHtml ()
 Get the introductory message HTML.
 
 getSubmitText ()
 Get the text for the submit button, either customised or a default.
 
 getTitle ()
 
 hasField ( $fieldname)
 
 loadData ()
 
 needsJSForHtml5FormValidation ()
 Whether this form, with its current fields, requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly.
 
 prepareForm ()
 Prepare form for submission.
 
 requestIsAuthorized ()
 Return true if the http request passes identity and csrf checks.
 
 setAction ( $action)
 Set the value for the action attribute of the form.
 
 setAutocomplete ( $autocomplete)
 Set the value for the autocomplete attribute of the form.
 
 setCancelTarget ( $target)
 Sets the target where the user is redirected to after clicking cancel.
 
 setCollapsibleOptions ( $collapsedByDefault=false)
 Enable collapsible mode, and set whether the form is collapsed by default.
 
 setDisplayFormat ( $format)
 Set format in which to display the form.
 
 setFooterHtml ( $html, $section=null)
 Set footer HTML, inside the form.
 
 setFormIdentifier (string $ident, bool $single=false)
 Set an internal identifier for this form.
 
 setHeaderHtml ( $html, $section=null)
 Set header HTML, inside the form.
 
 setId ( $id)
 
 setMessagePrefix ( $p)
 Set the prefix for various default messages.
 
 setMethod ( $method='post')
 Set the method used to submit the form.
 
 setName ( $name)
 
 setPostHtml ( $html)
 Set HTML at the end of the display.
 
 setPreHtml ( $html)
 Set the introductory message HTML, overwriting any existing message.
 
 setSections ( $sections)
 Set an array of information about sections.
 
 setSubmitCallback ( $cb)
 Set a callback to a function to do something with the form once it's been successfully validated.
 
 setSubmitDestructive ()
 Identify that the submit button in the form has a destructive action.
 
 setSubmitID ( $t)
 Set the id for the submit button.
 
 setSubmitName ( $name)
 
 setSubmitText ( $t)
 Set the text for the submit button.
 
 setSubmitTextMsg ( $msg)
 Set the text for the submit button to a message.
 
 setSubmitTooltip ( $name)
 
 setTableId ( $id)
 Set the id of the \<table\> or outermost \<div\> element.
 
 setTitle ( $t)
 Set the title for form submission.
 
 setTokenSalt ( $salt)
 Set the salt for the edit token.
 
 setValidationErrorMessage ( $msg)
 Set a message to display on a validation error.
 
 setWrapperAttributes ( $attributes)
 For internal use only.
 
 setWrapperLegend ( $legend)
 Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element.
 
 setWrapperLegendMsg ( $msg)
 Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
 
 show ()
 The here's-one-I-made-earlier option: do the submission if posted, or display the form with or without funky validation errors.
 
 showAlways ()
 Same as self::show with the difference, that the form will be added to the output, no matter, if the validation was good or not.
 
 showCancel ( $show=true)
 Show a cancel button (or prevent it).
 
 suppressDefaultSubmit ( $suppressSubmit=true)
 Stop a default submit button being shown for this form.
 
 tryAuthorizedSubmit ()
 Try submitting, with edit token check first.
 
 trySubmit ()
 Validate all the fields, and call the submission callback function if everything is kosher.
 
 wasSubmitted ()
 Test whether the form was considered to have been submitted or not, i.e.
 
 wrapForm ( $html)
 Wrap the form innards in an actual "<form>" element.
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Static Public Member Functions

static factory ( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='')
 Construct a HTMLForm object for given display type.
 
static getClassFromDescriptor ( $fieldname, &$descriptor)
 Get the HTMLFormField subclass for this descriptor.
 
static loadInputFromParameters ( $fieldname, $descriptor, self $parent)
 Initialise a new Object for the field.
 

Public Attributes

array $mFieldData
 

Static Public Attributes

static string[] $typeMappings
 A mapping of 'type' inputs onto standard HTMLFormField subclasses.
 

Protected Member Functions

 formatField (HTMLFormField $field, $value)
 Generate the HTML for an individual field in the current display format.
 
 formatSection (array $fieldsHtml, $sectionName, $anyFieldHasLabel)
 Put a form section together from the individual fields' HTML, merging it and wrapping.
 
 getCancelTargetURL ()
 
 getFormAttributes ()
 Get HTML attributes for the <form> tag.
 
 getMessage ( $value)
 Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message.
 
 loadFieldData ()
 Load data of form fields from the request.
 
 wrapFieldSetSection ( $legend, $section, $attributes, $isRoot)
 Wraps the given $section into a user-visible fieldset.
 

Protected Attributes

array $availableDisplayFormats
 Available formats in which to display the form.
 
array $availableSubclassDisplayFormats
 Available formats in which to display the form.
 
string $displayFormat = 'table'
 Format in which to display form.
 
string false $mAction = false
 Form action URL.
 
string null $mAutocomplete = null
 Form attribute autocomplete.
 
array[] $mButtons = []
 
LinkTarget string null $mCancelTarget
 
bool $mCollapsed = false
 Whether the form is collapsed by default.
 
bool $mCollapsible = false
 Whether the form can be collapsed.
 
array $mFieldTree = []
 
HTMLFormField[] $mFlatFields = []
 
string $mFooter = ''
 
string null $mFormIdentifier
 
string $mHeader = ''
 
array[] $mHiddenFields = []
 
string null $mId
 
string $mMessagePrefix
 
string $mMethod = 'post'
 
string null $mName
 
string $mPost = ''
 
string $mPre = ''
 
string[] $mSectionFooters = []
 
string[] $mSectionHeaders = []
 
array[] $mSections = []
 Additional information about form sections.
 
bool $mShowCancel = false
 
bool $mShowSubmit = true
 
bool $mSingleForm = false
 
callable null $mSubmitCallback
 
string[] $mSubmitFlags = [ 'primary', 'progressive' ]
 
string null $mSubmitID
 
string null $mSubmitName
 
string null $mSubmitText
 
string null $mSubmitTooltip
 
bool $mSubSectionBeforeFields = true
 If true, sections that contain both fields and subsections will render their subsections before their fields.
 
string $mTableId = ''
 
Title null $mTitle
 
string array $mTokenSalt = ''
 Salt for the edit token.
 
bool $mUseMultipart = false
 
array[] $mValidationErrorMessage
 
bool $mWasSubmitted = false
 
array $mWrapperAttributes = []
 
string false $mWrapperLegend = false
 

Detailed Description

Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusable manner.

In order to generate the form, the HTMLForm object takes an array structure detailing the form fields available. Each element of the array is a basic property-list, including the type of field, the label it is to be given in the form, callbacks for validation and 'filtering', and other pertinent information.

Field types are implemented as subclasses of the generic HTMLFormField object, and typically implement at least getInputHTML, which generates the HTML for the input field to be placed in the table.

You can find extensive documentation on the www.mediawiki.org wiki:

The constructor input is an associative array of $fieldname => $info, where $info is an Associative Array with any of the following:

'class' – the subclass of HTMLFormField that will be used to create the object. NOT the CSS class! 'type' – roughly translates into the <select> type attribute. if 'class' is not specified, this is used as a map through HTMLForm::$typeMappings to get the class name. 'default' – default value when the form is displayed 'nodata' – if set (to any value, which casts to true), the data for this field will not be loaded from the actual request. Instead, always the default data is set as the value of this field. 'id' – HTML id attribute 'cssclass' – CSS class 'csshelpclass' – CSS class used to style help text 'dir' – Direction of the element. 'options' – associative array mapping raw HTML labels to values. Some field types support multi-level arrays. Overwrites 'options-message'. 'options-messages' – associative array mapping message keys to values. Some field types support multi-level arrays. Overwrites 'options' and 'options-message'. 'options-messages-parse' – Flag to parse the messages in 'options-messages'. 'options-message' – message key or object to be parsed to extract the list of options (like 'ipbreason-dropdown'). 'label-message' – message key or object for a message to use as the label. can be an array of msg key and then parameters to the message. 'label' – alternatively, a raw text message. Overridden by label-message 'description-raw' – message text for a message to use as a description text. 'description-message' – message key or object for a message to use as a description text. can be an array of msg key and then parameters to the message. Overwrites 'description-messages' and 'description-raw'. 'description-messages'– array of message keys/objects. As above, each item can be an array of msg key and then parameters. Overwrites 'description-raw'. 'help-raw' – message text for a message to use as a help text. 'help-message' – message key or object for a message to use as a help text. can be an array of msg key and then parameters to the message. Overwrites 'help-messages' and 'help-raw'. 'help-messages' – array of message keys/objects. As above, each item can be an array of msg key and then parameters. Overwrites 'help-raw'. 'help-inline' – Whether help text (defined using options above) will be shown inline after the input field, rather than in a popup. Defaults to true. Only used by OOUI form fields. 'notices' – Array of plain text notices to display below the input field. Only used by OOUI form fields. 'required' – passed through to the object, indicating that it is a required field. 'show-optional-flag' – (Codex-only) adds an "(optional)" flag to the title to indicate that a field is not required. Must not have required=true. 'optional-message' – alternative message key to use for the flag shown with show-optional-flag 'size' – the length of text fields; (Codex-only) use large/medium/small for buttons 'filter-callback' – a function name to give you the chance to massage the inputted value before it's processed. See HTMLFormField::filter 'validation-callback' – a function name to give you the chance to impose extra validation on the field input. The signature should be as documented in HTMLFormField::$mValidationCallback. See HTMLFormField::validate 'name' – By default, the 'name' attribute of the input field is "wp{$fieldname}". If you want a different name (eg one without the "wp" prefix), specify it here and it will be used without modification. 'hide-if' – expression given as an array stating when the field should be hidden. The first array value has to be the expression's logic operator. Supported expressions: 'NOT' [ 'NOT', array $expression ] To hide a field if a given expression is not true. '===' [ '===', string $fieldName, string $value ] To hide a field if another field identified by $field has the value $value. '!==' [ '!==', string $fieldName, string $value ] Same as [ 'NOT', [ '===', $fieldName, $value ] 'OR', 'AND', 'NOR', 'NAND' [ 'XXX', array $expression1, ..., array $expressionN ] To hide a field if one or more (OR), all (AND), neither (NOR) or not all (NAND) given expressions are evaluated as true. The expressions will be given to a JavaScript frontend module which will continually update the field's visibility. 'disable-if' – expression given as an array stating when the field should be disabled. See 'hide-if' for supported expressions. The 'hide-if' logic would also disable fields, you don't need to set this attribute with the same condition manually. You can pass both 'disabled' and this attribute to omit extra check, but this would function only for not 'disabled' fields. 'hide-if-nojs', 'disable-if-nojs' – The 'hide-if' and 'disable-if' options documented above do not affect the initial HTML form rendering, to allow no-JavaScript users a full use of the form (even fields that would be initially hidden or disabled). If you want fields to be conditionally hidden or disabled in the initial HTML, requiring no-JS users to submit the form in order to access them, use these options instead. 'section' – A string name for the section of the form to which the field belongs. Subsections may be added using the separator '/', e.g.: 'section' => 'section1/subsection1' More levels may be added, e.g.: 'section' => 'section1/subsection2/subsubsection1' The message key for a section or subsection header is built from its name and the form's message prefix (if present).

Since 1.20, you can chain mutators to ease the form generation:

Example:
$form = new HTMLForm( $someFields, $this->getContext() );
$form->setMethod( 'get' )
->setWrapperLegendMsg( 'message-key' )
->prepareForm()
->displayForm( '' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:214
Note that you will have prepareForm and displayForm at the end. Other method calls done after that would simply not be part of the form :(
Stability: stable
to extend

Definition at line 214 of file HTMLForm.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\HTMLForm\HTMLForm::__construct ( $descriptor,
IContextSource $context,
$messagePrefix = '' )

Build a new HTMLForm from an array of field attributes.

Stability: stable
to call
Parameters
array$descriptorArray of Field constructs, as described in the class documentation
IContextSource$contextContext used to fetch submitted form fields and generate localisation messages
string$messagePrefixA prefix to go in front of default messages

Definition at line 483 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\addFields(), and MediaWiki\Context\ContextSource\setContext().

Member Function Documentation

◆ addButton()

MediaWiki\HTMLForm\HTMLForm::addButton ( $data)

Add a button to the form.

Since
1.27 takes an array as shown. Earlier versions accepted 'name', 'value', 'id', and 'attribs' as separate parameters in that order.
Parameters
array$dataData to define the button:
  • name: (string) Button name.
  • value: (string) Button value.
  • label-message: (string|array<string|array>|MessageSpecifier, optional) Button label message key to use instead of 'value'. Overrides 'label' and 'label-raw'.
  • label: (string, optional) Button label text to use instead of 'value'. Overrides 'label-raw'.
  • label-raw: (string, optional) Button label HTML to use instead of 'value'.
  • id: (string, optional) DOM id for the button.
  • attribs: (array, optional) Additional HTML attributes.
  • flags: (string|string[], optional) OOUI flags.
  • framed: (boolean=true, optional) OOUI framed attribute.
Returns
$this for chaining calls (since 1.20)

Definition at line 1152 of file HTMLForm.php.

Referenced by MediaWiki\Actions\McrUndoAction\alterForm(), and MediaWiki\Specials\SpecialBotPasswords\alterForm().

◆ addFields()

MediaWiki\HTMLForm\HTMLForm::addFields ( $descriptor)

Add fields to the form.

Since
1.34
Parameters
array$descriptorArray of Field constructs, as described in the class documentation
Returns
$this

Reimplemented in MediaWiki\Specials\Forms\PreferencesFormOOUI.

Definition at line 500 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\__construct(), and MediaWiki\Specials\SpecialWhatLinksHere\alterForm().

◆ addFooterHtml()

MediaWiki\HTMLForm\HTMLForm::addFooterHtml ( $html,
$section = null )

Add footer HTML, inside the form.

Parameters
string$htmlComplete text of message to display
string | null$sectionThe section to add the footer text to
Since
1.38
Returns
$this for chaining calls

Definition at line 986 of file HTMLForm.php.

Referenced by MediaWiki\Specials\Forms\UploadForm\__construct().

◆ addHeaderHtml()

MediaWiki\HTMLForm\HTMLForm::addHeaderHtml ( $html,
$section = null )

Add HTML to the header, inside the form.

Parameters
string$htmlAdditional HTML to display in header
string | null$sectionThe section to add the header to
Since
1.38
Returns
$this for chaining calls

Definition at line 935 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialBlock\alterForm(), MediaWiki\Specials\SpecialChangeEmail\alterForm(), MediaWiki\Specials\SpecialUserLogout\alterForm(), and MediaWiki\Specials\Forms\UploadForm\getDescriptionSection().

◆ addHiddenField()

MediaWiki\HTMLForm\HTMLForm::addHiddenField ( $name,
$value,
array $attribs = [] )

Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::getVal)

Parameters
string$nameField name. This will be used exactly as entered
mixed$valueField value
array$attribs
Returns
$this for chaining calls (since 1.20)

Definition at line 1096 of file HTMLForm.php.

Referenced by MediaWiki\Actions\McrRestoreAction\addStatePropagationFields(), MediaWiki\Actions\McrUndoAction\addStatePropagationFields(), MediaWiki\Actions\MarkpatrolledAction\alterForm(), MediaWiki\Actions\RevertAction\alterForm(), and MediaWiki\Actions\RollbackAction\alterForm().

◆ addHiddenFields()

MediaWiki\HTMLForm\HTMLForm::addHiddenFields ( array $fields)

Add an array of hidden fields to the output Array values are discarded for security reasons (per WebRequest::getVal)

Since
1.22
Parameters
array$fieldsAssociative array of fields to add; mapping names to their values
Returns
$this for chaining calls

Definition at line 1117 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialChangeEmail\alterForm(), MediaWiki\Specials\SpecialPasswordReset\alterForm(), and MediaWiki\Specials\SpecialUserLogout\alterForm().

◆ addPostHtml()

MediaWiki\HTMLForm\HTMLForm::addPostHtml ( $html)

Add HTML to the end of the display.

Parameters
string$htmlComplete text of message to display
Since
1.38
Returns
$this for chaining calls

Definition at line 1035 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialUnblock\execute().

◆ addPreHtml()

MediaWiki\HTMLForm\HTMLForm::addPreHtml ( $html)

Add HTML to introductory message.

Parameters
string$htmlComplete HTML of message to display
Since
1.38
Returns
$this for chaining calls

Definition at line 910 of file HTMLForm.php.

◆ displayForm()

MediaWiki\HTMLForm\HTMLForm::displayForm ( $submitResult)

Display the form (sending to the context's OutputPage object), with an appropriate error message or stack of messages, and any validation errors, etc.

Warning
You should call prepareForm() before calling this function. Moreover, when doing method chaining this should be the very last method call just after prepareForm().
Stability: stable
to override
Parameters
bool | string | array | Status$submitResultOutput from HTMLForm::trySubmit()
Returns
void Nothing, should be last call

Definition at line 1213 of file HTMLForm.php.

◆ displaySection()

MediaWiki\HTMLForm\HTMLForm::displaySection ( $fields,
$sectionName = '',
$fieldsetIDPrefix = '',
& $hasUserVisibleFields = false )
Todo
Document
Stability: stable
to override

Throws an exception when called on uninitialized field data, e.g. when HTMLForm::displayForm was called without calling HTMLForm::prepareForm first.

Parameters
array[] | HTMLFormField[]$fieldsArray of fields (either arrays or objects).
string$sectionNameID attribute of the "<table>" tag for this section, ignored if empty.
string$fieldsetIDPrefixID prefix for the "<fieldset>" tag of each subsection, ignored if empty.
bool&$hasUserVisibleFieldsWhether the section had user-visible fields.
Returns
string

Reimplemented in MediaWiki\Specials\Forms\EditWatchlistNormalHTMLForm.

Definition at line 1870 of file HTMLForm.php.

◆ factory()

static MediaWiki\HTMLForm\HTMLForm::factory ( $displayFormat,
$descriptor,
IContextSource $context,
$messagePrefix = '' )
static

Construct a HTMLForm object for given display type.

May return a HTMLForm subclass.

Stability: stable
to call
Parameters
string$displayFormat
array$descriptorArray of Field constructs, as described in the class documentation
IContextSource$contextContext used to fetch submitted form fields and generate localisation messages
string$messagePrefixA prefix to go in front of default messages
Returns
self

Definition at line 457 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\$displayFormat.

◆ filterDataForSubmit()

MediaWiki\HTMLForm\HTMLForm::filterDataForSubmit ( $data)

Overload this if you want to apply special filtration routines to the form as a whole, after it's submitted but before it's processed.

Stability: stable
to override
Parameters
array$data
Returns
array

Reimplemented in MediaWiki\Specials\Forms\PreferencesFormOOUI.

Definition at line 2068 of file HTMLForm.php.

◆ formatErrors()

MediaWiki\HTMLForm\HTMLForm::formatErrors ( $errors)

Format a stack of error messages into a single HTML string.

Parameters
array$errorsArray of message keys/values
Returns
string HTML, a "<ul>" list of errors

Definition at line 1511 of file HTMLForm.php.

◆ formatField()

MediaWiki\HTMLForm\HTMLForm::formatField ( HTMLFormField $field,
$value )
protected

Generate the HTML for an individual field in the current display format.

Since
1.41
Stability: stable
to override
Parameters
HTMLFormField$field
mixed$value
Returns
string|Stringable HTML

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, and MediaWiki\HTMLForm\OOUIHTMLForm.

Definition at line 1959 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLFormField\getDiv(), MediaWiki\HTMLForm\HTMLFormField\getInline(), MediaWiki\HTMLForm\HTMLFormField\getRaw(), and MediaWiki\HTMLForm\HTMLFormField\getTableRow().

◆ formatSection()

MediaWiki\HTMLForm\HTMLForm::formatSection ( array $fieldsHtml,
$sectionName,
$anyFieldHasLabel )
protected

Put a form section together from the individual fields' HTML, merging it and wrapping.

Stability: stable
to override
Parameters
array$fieldsHtmlArray of outputs from formatField()
string$sectionName
bool$anyFieldHasLabel
Returns
string HTML

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, and MediaWiki\HTMLForm\OOUIHTMLForm.

Definition at line 1983 of file HTMLForm.php.

◆ getAction()

MediaWiki\HTMLForm\HTMLForm::getAction ( )

Get the value for the action attribute of the form.

Since
1.22
Returns
string

Definition at line 2108 of file HTMLForm.php.

◆ getBody()

MediaWiki\HTMLForm\HTMLForm::getBody ( )

Get the whole body of the form.

Stability: stable
to override
Returns
string

Reimplemented in MediaWiki\HTMLForm\OOUIHTMLForm, and MediaWiki\Specials\Forms\PreferencesFormOOUI.

Definition at line 1457 of file HTMLForm.php.

◆ getButtons()

MediaWiki\HTMLForm\HTMLForm::getButtons ( )

Get the submit and (potentially) reset buttons.

Stability: stable
to override
Returns
string HTML.

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, and MediaWiki\HTMLForm\OOUIHTMLForm.

Definition at line 1381 of file HTMLForm.php.

◆ getCancelTargetURL()

MediaWiki\HTMLForm\HTMLForm::getCancelTargetURL ( )
protected
Since
1.37
Returns
string

Definition at line 1683 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\CodexHTMLForm\getButtons(), and MediaWiki\HTMLForm\OOUIHTMLForm\getButtons().

◆ getClassFromDescriptor()

static MediaWiki\HTMLForm\HTMLForm::getClassFromDescriptor ( $fieldname,
& $descriptor )
static

Get the HTMLFormField subclass for this descriptor.

The descriptor can be passed either 'class' which is the name of a HTMLFormField subclass, or a shorter 'type' which is an alias. This makes sure the 'class' is always set, and also is returned by this function for ease.

Since
1.23
Parameters
string$fieldnameName of the field
array&$descriptorInput Descriptor, as described in the class documentation
Returns
class-string<HTMLFormField> Name of a HTMLFormField subclass

Definition at line 608 of file HTMLForm.php.

◆ getDisplayFormat()

MediaWiki\HTMLForm\HTMLForm::getDisplayFormat ( )

Getter for displayFormat.

Since
1.20
Returns
string

Definition at line 588 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\$displayFormat.

Referenced by MediaWiki\HTMLForm\Field\HTMLCheckField\getLabel().

◆ getErrorsOrWarnings()

MediaWiki\HTMLForm\HTMLForm::getErrorsOrWarnings ( $elements,
$elementsType )

Returns a formatted list of errors or warnings from the given elements.

Stability: stable
to override
Parameters
string | array | Status$elementsThe set of errors/warnings to process.
string$elementsTypeShould warnings or errors be returned. This is meant for Status objects, all other valid types are always considered as errors.
Returns
string

Reimplemented in MediaWiki\HTMLForm\OOUIHTMLForm.

Definition at line 1470 of file HTMLForm.php.

◆ getField()

MediaWiki\HTMLForm\HTMLForm::getField ( $fieldname)
Parameters
string$fieldname
Returns
HTMLFormField
Exceptions
DomainExceptionon invalid field name

Definition at line 542 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\hasField().

◆ getFooterHtml()

MediaWiki\HTMLForm\HTMLForm::getFooterHtml ( $section = null)

Get footer HTML.

Parameters
string | null$sectionThe section to get the footer text for
Since
1.38
Returns
string

Definition at line 1023 of file HTMLForm.php.

◆ getFormAttributes()

MediaWiki\HTMLForm\HTMLForm::getFormAttributes ( )
protected

Get HTML attributes for the <form> tag.

Stability: stable
to override
Returns
array

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm.

Definition at line 1292 of file HTMLForm.php.

◆ getHeaderHtml()

MediaWiki\HTMLForm\HTMLForm::getHeaderHtml ( $section = null)

Get header HTML.

Stability: stable
to override
Parameters
string | null$sectionThe section to get the header text for
Since
1.38
Returns
string HTML

Reimplemented in MediaWiki\HTMLForm\OOUIHTMLForm.

Definition at line 973 of file HTMLForm.php.

◆ getHiddenFields()

MediaWiki\HTMLForm\HTMLForm::getHiddenFields ( )

Get the hidden fields that should go inside the form.

Returns
string HTML.

Definition at line 1348 of file HTMLForm.php.

◆ getHTML()

MediaWiki\HTMLForm\HTMLForm::getHTML ( $submitResult)

Returns the raw HTML generated by the form.

Stability: stable
to override
Parameters
bool | string | array | Status$submitResultOutput from HTMLForm::trySubmit()
Returns
string HTML

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm.

Definition at line 1245 of file HTMLForm.php.

◆ getLegend()

MediaWiki\HTMLForm\HTMLForm::getLegend ( $key)

Get a string to go in the "<legend>" of a section fieldset.

Override this if you want something more complicated.

Stability: stable
to override
Parameters
string$key
Returns
string Plain text (not HTML-escaped)

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, MediaWiki\Specials\Forms\PreferencesFormOOUI, and MediaWiki\Specials\Forms\EditWatchlistNormalHTMLForm.

Definition at line 2081 of file HTMLForm.php.

◆ getMessage()

MediaWiki\HTMLForm\HTMLForm::getMessage ( $value)
protected

Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message.

Parameters
mixed$value
Returns
Message

Definition at line 2149 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\CodexHTMLForm\getButtons(), MediaWiki\HTMLForm\OOUIHTMLForm\getButtons(), and MediaWiki\HTMLForm\OOUIHTMLForm\getErrorsOrWarnings().

◆ getMethod()

MediaWiki\HTMLForm\HTMLForm::getMethod ( )
Returns
string Always lowercase

Definition at line 1830 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\prepareForm().

◆ getPostHtml()

MediaWiki\HTMLForm\HTMLForm::getPostHtml ( )

Get HTML at the end of the display.

Since
1.38
Returns
string HTML

Definition at line 1061 of file HTMLForm.php.

◆ getPreHtml()

MediaWiki\HTMLForm\HTMLForm::getPreHtml ( )

Get the introductory message HTML.

Since
1.38
Returns
string

Definition at line 922 of file HTMLForm.php.

◆ getSubmitText()

MediaWiki\HTMLForm\HTMLForm::getSubmitText ( )

Get the text for the submit button, either customised or a default.

Returns
string

Definition at line 1572 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\CodexHTMLForm\getButtons(), and MediaWiki\HTMLForm\OOUIHTMLForm\getButtons().

◆ getTitle()

MediaWiki\HTMLForm\HTMLForm::getTitle ( )

◆ hasField()

MediaWiki\HTMLForm\HTMLForm::hasField ( $fieldname)
Parameters
string$fieldname
Returns
bool

Definition at line 533 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\getField().

◆ loadData()

MediaWiki\HTMLForm\HTMLForm::loadData ( )
Deprecated
since 1.39, Use prepareForm() instead.

Definition at line 2018 of file HTMLForm.php.

◆ loadFieldData()

MediaWiki\HTMLForm\HTMLForm::loadFieldData ( )
protected

Load data of form fields from the request.

Definition at line 2025 of file HTMLForm.php.

References $request.

Referenced by MediaWiki\HTMLForm\HTMLForm\prepareForm().

◆ loadInputFromParameters()

static MediaWiki\HTMLForm\HTMLForm::loadInputFromParameters ( $fieldname,
$descriptor,
self $parent )
static

Initialise a new Object for the field.

Stability: stable
to override
Parameters
string$fieldnameName of the field
array$descriptorInput Descriptor, as described in the class documentation
self$parentParent instance of HTMLForm
Returns
HTMLFormField Instance of a subclass of HTMLFormField

Definition at line 637 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLFormFieldCloner\createFieldsForKey().

◆ needsJSForHtml5FormValidation()

MediaWiki\HTMLForm\HTMLForm::needsJSForHtml5FormValidation ( )

Whether this form, with its current fields, requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly.

If this function returns true, a 'novalidate' attribute will be added on the <form> element. It will be removed if the user agent has JavaScript support, in htmlform.js.

Returns
bool
Since
1.29

Definition at line 2162 of file HTMLForm.php.

◆ prepareForm()

MediaWiki\HTMLForm\HTMLForm::prepareForm ( )

Prepare form for submission.

Warning
When doing method chaining, that should be the very last method call before displayForm().
Returns
$this for chaining calls (since 1.20)

Definition at line 657 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\getMethod(), MediaWiki\Context\ContextSource\getRequest(), and MediaWiki\HTMLForm\HTMLForm\loadFieldData().

◆ requestIsAuthorized()

MediaWiki\HTMLForm\HTMLForm::requestIsAuthorized ( )

Return true if the http request passes identity and csrf checks.

Since
1.46
Returns
bool

Definition at line 692 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\tryAuthorizedSubmit().

◆ setAction()

MediaWiki\HTMLForm\HTMLForm::setAction ( $action)

Set the value for the action attribute of the form.

When set to false (which is the default state), the set title is used.

Since
1.19
Parameters
string | bool$action
Returns
$this for chaining calls (since 1.20)

Definition at line 2095 of file HTMLForm.php.

Referenced by MediaWiki\Actions\DeleteAction\alterForm().

◆ setAutocomplete()

MediaWiki\HTMLForm\HTMLForm::setAutocomplete ( $autocomplete)

Set the value for the autocomplete attribute of the form.

A typical value is "off". When set to null (which is the default state), the attribute get not set.

Since
1.27
Parameters
string | null$autocomplete
Returns
$this for chaining calls

Definition at line 2137 of file HTMLForm.php.

◆ setCancelTarget()

MediaWiki\HTMLForm\HTMLForm::setCancelTarget ( $target)

Sets the target where the user is redirected to after clicking cancel.

Parameters
LinkTarget | PageReference | string$targetTarget as an object or an URL
Returns
$this for chaining calls
Since
1.27

Definition at line 1670 of file HTMLForm.php.

Referenced by MediaWiki\Actions\McrUndoAction\alterForm().

◆ setCollapsibleOptions()

MediaWiki\HTMLForm\HTMLForm::setCollapsibleOptions ( $collapsedByDefault = false)

Enable collapsible mode, and set whether the form is collapsed by default.

Since
1.34
Parameters
bool$collapsedByDefaultWhether the form is collapsed by default (optional).
Returns
$this for chaining calls

Definition at line 1281 of file HTMLForm.php.

◆ setDisplayFormat()

MediaWiki\HTMLForm\HTMLForm::setDisplayFormat ( $format)

Set format in which to display the form.

Parameters
string$formatThe name of the format to use, must be one of $this->availableDisplayFormats
Since
1.20
Returns
$this for chaining calls (since 1.20)

Definition at line 558 of file HTMLForm.php.

◆ setFooterHtml()

MediaWiki\HTMLForm\HTMLForm::setFooterHtml ( $html,
$section = null )

Set footer HTML, inside the form.

Parameters
string$htmlComplete text of message to display
string | null$sectionThe section to add the footer text to
Since
1.38
Returns
$this for chaining calls

Definition at line 1006 of file HTMLForm.php.

◆ setFormIdentifier()

MediaWiki\HTMLForm\HTMLForm::setFormIdentifier ( string $ident,
bool $single = false )

Set an internal identifier for this form.

It will be submitted as a hidden form field, allowing HTMLForm to determine whether the form was submitted (or merely viewed). Setting this serves two purposes:

  • If you use two or more forms on one page with the same submit target, it allows HTMLForm to identify which of the forms was submitted, and not attempt to validate the other ones.
  • If you use checkbox or multiselect fields inside a form using the GET method, it allows HTMLForm to distinguish between the initial page view and a form submission with all checkboxes or select options unchecked. Set the second parameter to true if you are sure this is the only form on the page, which allows form fields to be prefilled with query params.
Since
1.28
Parameters
string$ident
bool$singleOnly work with GET form, see above. (since 1.41)
Returns
$this

Definition at line 1630 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialChangeContentModel\alterForm().

◆ setHeaderHtml()

MediaWiki\HTMLForm\HTMLForm::setHeaderHtml ( $html,
$section = null )

Set header HTML, inside the form.

Parameters
string$htmlComplete HTML of header to display
string | null$sectionThe section to add the header to
Since
1.38
Returns
$this for chaining calls

Definition at line 955 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialBlock\alterForm(), and MediaWiki\Specials\SpecialPasswordReset\alterForm().

◆ setId()

◆ setMessagePrefix()

MediaWiki\HTMLForm\HTMLForm::setMessagePrefix ( $p)

Set the prefix for various default messages.

Todo
Currently only used for the "<fieldset>" legend on forms with multiple sections; should be used elsewhere?
Parameters
string$p
Returns
$this for chaining calls (since 1.20)

Definition at line 1787 of file HTMLForm.php.

◆ setMethod()

MediaWiki\HTMLForm\HTMLForm::setMethod ( $method = 'post')

Set the method used to submit the form.

Parameters
string$method
Returns
$this for chaining calls (since 1.20)

Definition at line 1821 of file HTMLForm.php.

Referenced by MediaWiki\Specials\Redirects\SpecialTalkPage\alterForm().

◆ setName()

MediaWiki\HTMLForm\HTMLForm::setName ( $name)
Parameters
string$name'name' attribute for the form
Returns
$this for chaining calls

Definition at line 1723 of file HTMLForm.php.

◆ setPostHtml()

MediaWiki\HTMLForm\HTMLForm::setPostHtml ( $html)

Set HTML at the end of the display.

Parameters
string$htmlComplete text of message to display
Since
1.38
Returns
$this for chaining calls

Definition at line 1049 of file HTMLForm.php.

◆ setPreHtml()

MediaWiki\HTMLForm\HTMLForm::setPreHtml ( $html)

Set the introductory message HTML, overwriting any existing message.

Parameters
string$htmlComplete HTML of message to display
Since
1.38
Returns
$this for chaining calls

Definition at line 896 of file HTMLForm.php.

◆ setSections()

MediaWiki\HTMLForm\HTMLForm::setSections ( $sections)

Set an array of information about sections.

Since
1.42
Parameters
array[]$sectionsArray of section information, keyed on section name.
Returns
$this for chaining calls

Definition at line 1074 of file HTMLForm.php.

◆ setSubmitCallback()

MediaWiki\HTMLForm\HTMLForm::setSubmitCallback ( $cb)

Set a callback to a function to do something with the form once it's been successfully validated.

Parameters
callable$cbThe function will be passed the output from HTMLForm::filterDataForSubmit and this HTMLForm object, and must return as documented for HTMLForm::trySubmit
Returns
$this for chaining calls (since 1.20)

Definition at line 867 of file HTMLForm.php.

◆ setSubmitDestructive()

MediaWiki\HTMLForm\HTMLForm::setSubmitDestructive ( )

Identify that the submit button in the form has a destructive action.

Since
1.24
Returns
$this for chaining calls (since 1.28)

Definition at line 1545 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialBlock\alterForm(), and MediaWiki\Specials\SpecialResetTokens\alterForm().

◆ setSubmitID()

MediaWiki\HTMLForm\HTMLForm::setSubmitID ( $t)

Set the id for the submit button.

Parameters
string$t
Todo
FIXME: Integrity of $t is not validated
Returns
$this for chaining calls (since 1.20)

Definition at line 1606 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialChangeEmail\alterForm().

◆ setSubmitName()

MediaWiki\HTMLForm\HTMLForm::setSubmitName ( $name)
Parameters
string$nameSubmit button name
Returns
$this for chaining calls (since 1.20)

Definition at line 1581 of file HTMLForm.php.

Referenced by MediaWiki\Specials\Forms\UploadForm\__construct(), and MediaWiki\Actions\McrUndoAction\alterForm().

◆ setSubmitText()

MediaWiki\HTMLForm\HTMLForm::setSubmitText ( $t)

Set the text for the submit button.

Parameters
string$tPlaintext
Returns
$this for chaining calls (since 1.20)

Definition at line 1533 of file HTMLForm.php.

◆ setSubmitTextMsg()

◆ setSubmitTooltip()

MediaWiki\HTMLForm\HTMLForm::setSubmitTooltip ( $name)
Parameters
string$nameTooltip for the submit button
Returns
$this for chaining calls (since 1.20)

Definition at line 1592 of file HTMLForm.php.

Referenced by MediaWiki\Specials\Forms\UploadForm\__construct(), and MediaWiki\Actions\McrUndoAction\alterForm().

◆ setTableId()

MediaWiki\HTMLForm\HTMLForm::setTableId ( $id)

Set the id of the \<table\> or outermost \<div\> element.

Since
1.22
Parameters
string$idNew value of the id attribute, or "" to remove
Returns
$this for chaining calls

Definition at line 1702 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialBotPasswords\alterForm(), and MediaWiki\Specials\SpecialChangeEmail\alterForm().

◆ setTitle()

MediaWiki\HTMLForm\HTMLForm::setTitle ( $t)

Set the title for form submission.

Parameters
PageReference$tThe page the form is on/should be posted to
Returns
$this for chaining calls (since 1.20)

Definition at line 1800 of file HTMLForm.php.

◆ setTokenSalt()

MediaWiki\HTMLForm\HTMLForm::setTokenSalt ( $salt)

Set the salt for the edit token.

Only useful when the method is "post".

Since
1.24
Parameters
string | array$saltSalt to use
Returns
$this For chaining calls

Definition at line 1193 of file HTMLForm.php.

Referenced by MediaWiki\Actions\MarkpatrolledAction\alterForm(), MediaWiki\Actions\RevertAction\alterForm(), MediaWiki\Actions\RollbackAction\alterForm(), MediaWiki\Actions\WatchAction\alterForm(), and MediaWiki\Specials\SpecialUserLogout\alterForm().

◆ setValidationErrorMessage()

MediaWiki\HTMLForm\HTMLForm::setValidationErrorMessage ( $msg)

Set a message to display on a validation error.

Parameters
array[]$msgArray of valid inputs to wfMessage() (so each entry must itself be an array of arguments)
Returns
$this for chaining calls (since 1.20)

Definition at line 882 of file HTMLForm.php.

◆ setWrapperAttributes()

MediaWiki\HTMLForm\HTMLForm::setWrapperAttributes ( $attributes)

For internal use only.

Use is discouraged, and should only be used where support for gadgets/user scripts is warranted.

Parameters
array$attributes
Access: internal
Returns
$this for chaining calls

Definition at line 1754 of file HTMLForm.php.

◆ setWrapperLegend()

MediaWiki\HTMLForm\HTMLForm::setWrapperLegend ( $legend)

Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element.

Parameters
string | bool$legendIf false, no wrapper or legend will be displayed. If true, a wrapper will be displayed, but no legend. If a string, a wrapper will be displayed with that string as a legend. The string will be escaped before being output (this doesn't support HTML).
Returns
$this for chaining calls (since 1.20)

Definition at line 1741 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialLockdb\alterForm(), and MediaWiki\Specials\SpecialUnlockdb\alterForm().

◆ setWrapperLegendMsg()

MediaWiki\HTMLForm\HTMLForm::setWrapperLegendMsg ( $msg)

Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.

Since
1.19
Parameters
string | Message$msgMessage key or Message object
Returns
$this for chaining calls (since 1.20)

Definition at line 1769 of file HTMLForm.php.

Referenced by MediaWiki\Actions\McrRestoreAction\alterForm(), MediaWiki\Actions\McrUndoAction\alterForm(), MediaWiki\Actions\PurgeAction\alterForm(), MediaWiki\Actions\RevertAction\alterForm(), MediaWiki\Actions\RollbackAction\alterForm(), MediaWiki\Actions\UnwatchAction\alterForm(), MediaWiki\Actions\WatchAction\alterForm(), MediaWiki\Specials\SpecialBotPasswords\alterForm(), and MediaWiki\Specials\SpecialWhatLinksHere\alterForm().

◆ show()

MediaWiki\HTMLForm\HTMLForm::show ( )

The here's-one-I-made-earlier option: do the submission if posted, or display the form with or without funky validation errors.

Stability: stable
to override
Returns
bool|Status Whether submission was successful.

Reimplemented in MediaWiki\Specials\Forms\UploadForm.

Definition at line 725 of file HTMLForm.php.

References StatusValue\isGood().

Referenced by MediaWiki\Specials\SpecialUnblock\execute().

◆ showAlways()

MediaWiki\HTMLForm\HTMLForm::showAlways ( )

Same as self::show with the difference, that the form will be added to the output, no matter, if the validation was good or not.

Returns
bool|Status Whether submission was successful.

Definition at line 743 of file HTMLForm.php.

◆ showCancel()

MediaWiki\HTMLForm\HTMLForm::showCancel ( $show = true)

Show a cancel button (or prevent it).

The button is not shown by default.

Parameters
bool$show
Returns
$this for chaining calls
Since
1.27

Definition at line 1659 of file HTMLForm.php.

Referenced by MediaWiki\Actions\McrUndoAction\alterForm().

◆ suppressDefaultSubmit()

MediaWiki\HTMLForm\HTMLForm::suppressDefaultSubmit ( $suppressSubmit = true)

Stop a default submit button being shown for this form.

This implies that an alternate submit method must be provided manually.

Since
1.22
Parameters
bool$suppressSubmitSet to false to re-enable the button again
Returns
$this for chaining calls

Definition at line 1647 of file HTMLForm.php.

Referenced by MediaWiki\Specials\SpecialBotPasswords\alterForm(), MediaWiki\Specials\SpecialResetTokens\alterForm(), MediaWiki\Specials\Forms\PreferencesFormOOUI\setOptionsEditable(), and MediaWiki\Specials\Forms\PreferencesFormOOUI\setPrivateInfoEditable().

◆ tryAuthorizedSubmit()

MediaWiki\HTMLForm\HTMLForm::tryAuthorizedSubmit ( )

Try submitting, with edit token check first.

Returns
bool|string|array|Status As documented for HTMLForm::trySubmit

Definition at line 676 of file HTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\requestIsAuthorized(), and MediaWiki\HTMLForm\HTMLForm\trySubmit().

◆ trySubmit()

MediaWiki\HTMLForm\HTMLForm::trySubmit ( )

Validate all the fields, and call the submission callback function if everything is kosher.

Stability: stable
to override
Returns
bool|string|array|Status
  • Bool true or a good Status object indicates success,
  • Bool false indicates no submission was attempted,
  • Anything else indicates failure. The value may be a fatal Status object, an HTML string, or an array of arrays (message keys and params) or strings (message keys)

Reimplemented in MediaWiki\Specials\Forms\UploadForm.

Definition at line 764 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\tryAuthorizedSubmit().

◆ wasSubmitted()

MediaWiki\HTMLForm\HTMLForm::wasSubmitted ( )

Test whether the form was considered to have been submitted or not, i.e.

whether the last call to tryAuthorizedSubmit or trySubmit returned non-false.

This will return false until HTMLForm::tryAuthorizedSubmit or HTMLForm::trySubmit is called.

Since
1.23
Returns
bool

Definition at line 853 of file HTMLForm.php.

◆ wrapFieldSetSection()

MediaWiki\HTMLForm\HTMLForm::wrapFieldSetSection ( $legend,
$section,
$attributes,
$isRoot )
protected

Wraps the given $section into a user-visible fieldset.

Stability: stable
to override
Parameters
string$legendLegend text for the fieldset
string$sectionThe section content in plain Html
array$attributesAdditional attributes for the fieldset
bool$isRootSection is at the root of the tree
Returns
string The fieldset's Html

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, MediaWiki\HTMLForm\OOUIHTMLForm, and MediaWiki\Specials\Forms\PreferencesFormOOUI.

Definition at line 1844 of file HTMLForm.php.

◆ wrapForm()

MediaWiki\HTMLForm\HTMLForm::wrapForm ( $html)

Wrap the form innards in an actual "<form>" element.

Stability: stable
to override
Parameters
string$htmlHTML contents to wrap.
Returns
string|\OOUI\Tag Wrapped HTML.

Reimplemented in MediaWiki\HTMLForm\CodexHTMLForm, MediaWiki\HTMLForm\OOUIHTMLForm, and MediaWiki\Specials\Forms\PreferencesFormOOUI.

Definition at line 1326 of file HTMLForm.php.

Member Data Documentation

◆ $availableDisplayFormats

array MediaWiki\HTMLForm\HTMLForm::$availableDisplayFormats
protected
Initial value:
= [
'table',
'div',
'raw',
'inline',
]

Available formats in which to display the form.

Definition at line 422 of file HTMLForm.php.

◆ $availableSubclassDisplayFormats

array MediaWiki\HTMLForm\HTMLForm::$availableSubclassDisplayFormats
protected
Initial value:
= [
'codex',
'ooui',
]

Available formats in which to display the form.

Definition at line 433 of file HTMLForm.php.

◆ $displayFormat

string MediaWiki\HTMLForm\HTMLForm::$displayFormat = 'table'
protected

Format in which to display form.

For viable options,

See also
$availableDisplayFormats

Definition at line 416 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\HTMLForm\factory(), and MediaWiki\HTMLForm\HTMLForm\getDisplayFormat().

◆ $mAction

string false MediaWiki\HTMLForm\HTMLForm::$mAction = false
protected

Form action URL.

false means we will use the URL to set Title

Since
1.19

Definition at line 340 of file HTMLForm.php.

◆ $mAutocomplete

string null MediaWiki\HTMLForm\HTMLForm::$mAutocomplete = null
protected

Form attribute autocomplete.

A typical value is "off". null does not set the attribute

Since
1.27

Definition at line 361 of file HTMLForm.php.

◆ $mButtons

array [] MediaWiki\HTMLForm\HTMLForm::$mButtons = []
protected

Definition at line 374 of file HTMLForm.php.

◆ $mCancelTarget

LinkTarget string null MediaWiki\HTMLForm\HTMLForm::$mCancelTarget
protected

Definition at line 285 of file HTMLForm.php.

◆ $mCollapsed

bool MediaWiki\HTMLForm\HTMLForm::$mCollapsed = false
protected

Whether the form is collapsed by default.

Since
1.34

Definition at line 354 of file HTMLForm.php.

◆ $mCollapsible

bool MediaWiki\HTMLForm\HTMLForm::$mCollapsible = false
protected

Whether the form can be collapsed.

Since
1.34

Definition at line 347 of file HTMLForm.php.

◆ $mFieldData

array MediaWiki\HTMLForm\HTMLForm::$mFieldData

Definition at line 269 of file HTMLForm.php.

◆ $mFieldTree

array MediaWiki\HTMLForm\HTMLForm::$mFieldTree = []
protected

Definition at line 277 of file HTMLForm.php.

◆ $mFlatFields

HTMLFormField [] MediaWiki\HTMLForm\HTMLForm::$mFlatFields = []
protected

Definition at line 275 of file HTMLForm.php.

◆ $mFooter

string MediaWiki\HTMLForm\HTMLForm::$mFooter = ''
protected

Definition at line 300 of file HTMLForm.php.

◆ $mFormIdentifier

string null MediaWiki\HTMLForm\HTMLForm::$mFormIdentifier
protected

Definition at line 324 of file HTMLForm.php.

◆ $mHeader

string MediaWiki\HTMLForm\HTMLForm::$mHeader = ''
protected

Definition at line 298 of file HTMLForm.php.

◆ $mHiddenFields

array [] MediaWiki\HTMLForm\HTMLForm::$mHiddenFields = []
protected

Definition at line 369 of file HTMLForm.php.

◆ $mId

string null MediaWiki\HTMLForm\HTMLForm::$mId
protected

Definition at line 308 of file HTMLForm.php.

◆ $mMessagePrefix

string MediaWiki\HTMLForm\HTMLForm::$mMessagePrefix
protected

Definition at line 272 of file HTMLForm.php.

◆ $mMethod

string MediaWiki\HTMLForm\HTMLForm::$mMethod = 'post'
protected

Definition at line 331 of file HTMLForm.php.

◆ $mName

string null MediaWiki\HTMLForm\HTMLForm::$mName
protected

Definition at line 310 of file HTMLForm.php.

◆ $mPost

string MediaWiki\HTMLForm\HTMLForm::$mPost = ''
protected

Definition at line 306 of file HTMLForm.php.

◆ $mPre

string MediaWiki\HTMLForm\HTMLForm::$mPre = ''
protected

Definition at line 296 of file HTMLForm.php.

◆ $mSectionFooters

string [] MediaWiki\HTMLForm\HTMLForm::$mSectionFooters = []
protected

Definition at line 304 of file HTMLForm.php.

◆ $mSectionHeaders

string [] MediaWiki\HTMLForm\HTMLForm::$mSectionHeaders = []
protected

Definition at line 302 of file HTMLForm.php.

◆ $mSections

array [] MediaWiki\HTMLForm\HTMLForm::$mSections = []
protected

Additional information about form sections.

Only supported by CodexHTMLForm.

Array is keyed on section name. Options per section include: 'description' – Description text placed below the section label. 'description-message' – The same, but a message key. 'description-message-parse' – Whether to parse the 'description-message' 'optional' – Whether the section should be marked as optional.

Since
1.42

Definition at line 399 of file HTMLForm.php.

◆ $mShowCancel

bool MediaWiki\HTMLForm\HTMLForm::$mShowCancel = false
protected

Definition at line 283 of file HTMLForm.php.

◆ $mShowSubmit

bool MediaWiki\HTMLForm\HTMLForm::$mShowSubmit = true
protected

Definition at line 279 of file HTMLForm.php.

◆ $mSingleForm

bool MediaWiki\HTMLForm\HTMLForm::$mSingleForm = false
protected

Definition at line 326 of file HTMLForm.php.

◆ $mSubmitCallback

callable null MediaWiki\HTMLForm\HTMLForm::$mSubmitCallback
protected

Definition at line 288 of file HTMLForm.php.

◆ $mSubmitFlags

string [] MediaWiki\HTMLForm\HTMLForm::$mSubmitFlags = [ 'primary', 'progressive' ]
protected

◆ $mSubmitID

string null MediaWiki\HTMLForm\HTMLForm::$mSubmitID
protected

◆ $mSubmitName

string null MediaWiki\HTMLForm\HTMLForm::$mSubmitName
protected

◆ $mSubmitText

string null MediaWiki\HTMLForm\HTMLForm::$mSubmitText
protected

Definition at line 319 of file HTMLForm.php.

◆ $mSubmitTooltip

string null MediaWiki\HTMLForm\HTMLForm::$mSubmitTooltip
protected

Definition at line 321 of file HTMLForm.php.

◆ $mSubSectionBeforeFields

bool MediaWiki\HTMLForm\HTMLForm::$mSubSectionBeforeFields = true
protected

If true, sections that contain both fields and subsections will render their subsections before their fields.

Subclasses may set this to false to render subsections after fields instead.

Definition at line 409 of file HTMLForm.php.

◆ $mTableId

string MediaWiki\HTMLForm\HTMLForm::$mTableId = ''
protected

Definition at line 312 of file HTMLForm.php.

◆ $mTitle

Title null MediaWiki\HTMLForm\HTMLForm::$mTitle
protected

Definition at line 329 of file HTMLForm.php.

◆ $mTokenSalt

string array MediaWiki\HTMLForm\HTMLForm::$mTokenSalt = ''
protected

Salt for the edit token.

Definition at line 385 of file HTMLForm.php.

◆ $mUseMultipart

bool MediaWiki\HTMLForm\HTMLForm::$mUseMultipart = false
protected

Definition at line 364 of file HTMLForm.php.

◆ $mValidationErrorMessage

array [] MediaWiki\HTMLForm\HTMLForm::$mValidationErrorMessage
protected

Definition at line 293 of file HTMLForm.php.

◆ $mWasSubmitted

bool MediaWiki\HTMLForm\HTMLForm::$mWasSubmitted = false
protected

Definition at line 333 of file HTMLForm.php.

◆ $mWrapperAttributes

array MediaWiki\HTMLForm\HTMLForm::$mWrapperAttributes = []
protected

Definition at line 379 of file HTMLForm.php.

◆ $mWrapperLegend

string false MediaWiki\HTMLForm\HTMLForm::$mWrapperLegend = false
protected

Definition at line 377 of file HTMLForm.php.

◆ $typeMappings

string [] MediaWiki\HTMLForm\HTMLForm::$typeMappings
static

A mapping of 'type' inputs onto standard HTMLFormField subclasses.

Definition at line 218 of file HTMLForm.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLExpiryField\getFieldByType().


The documentation for this class was generated from the following file: