MediaWiki master
MediaWiki\HTMLForm\HTMLFormField Class Reference

The parent class to generate form fields. More...

Inherited by Licenses, MediaWiki\HTMLForm\Field\HTMLApiField, MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckField, MediaWiki\HTMLForm\Field\HTMLCheckMatrix, MediaWiki\HTMLForm\Field\HTMLEditTools, MediaWiki\HTMLForm\Field\HTMLExpiryField, MediaWiki\HTMLForm\Field\HTMLFileField, MediaWiki\HTMLForm\Field\HTMLFormFieldCloner, MediaWiki\HTMLForm\Field\HTMLFormFieldWithButton, MediaWiki\HTMLForm\Field\HTMLHiddenField, MediaWiki\HTMLForm\Field\HTMLInfoField, MediaWiki\HTMLForm\Field\HTMLMultiSelectField, MediaWiki\HTMLForm\Field\HTMLRadioField, MediaWiki\HTMLForm\Field\HTMLRestrictionsField, MediaWiki\HTMLForm\Field\HTMLSelectField, MediaWiki\HTMLForm\Field\HTMLSelectNamespace, MediaWiki\HTMLForm\Field\HTMLTagFilter, MediaWiki\HTMLForm\Field\HTMLTextAreaField, and MediaWiki\HTMLForm\Field\HTMLTextField.

Collaboration diagram for MediaWiki\HTMLForm\HTMLFormField:

Public Member Functions

 __construct ( $params)
 Initialise the object.
 
 cancelSubmit ( $value, $alldata)
 Override this function if the control can somehow trigger a form submission that shouldn't actually submit the HTMLForm.
 
 canDisplayErrors ()
 True if this field type is able to display errors; false if validation errors need to be displayed in the main HTMLForm error area.
 
 filter ( $value, $alldata)
 
 getAttributes (array $list)
 Returns the given attributes from the parameters.
 
 getCodex ( $value)
 Get the Codex version of the div.
 
 getDefault ()
 
 getDiv ( $value)
 Get the complete div for the input, including help text, labels, and whatever.
 
 getErrorsAndErrorClass ( $value)
 Determine form errors to display and their classes.
 
 getErrorsRaw ( $value)
 Determine form errors to display, returning them in an array.
 
 getHelpText ()
 Determine the help text to display.
 
 getHelpTextHtmlDiv ( $helptext, $cssClasses=[])
 Generate help text HTML in div format.
 
 getHelpTextHtmlRaw ( $helptext)
 Generate help text HTML formatted for raw output.
 
 getHelpTextHtmlTable ( $helptext)
 Generate help text HTML in table format.
 
 getInline ( $value)
 Get the complete field as an inline element.
 
 getInputCodex ( $value, $hasErrors)
 Same as getInputHTML, but for Codex.
 
 getInputHTML ( $value)
 This function must be implemented to return the HTML to generate the input object itself.
 
 getInputOOUI ( $value)
 Same as getInputHTML, but returns an OOUI object.
 
 getLabel ()
 
 getLabelHtml ( $cellAttributes=[])
 
 getName ()
 Get the field name that will be used for submission.
 
 getOOUI ( $value)
 Get the OOUI version of the div.
 
 getOptions ()
 Fetch the array of options from the field's parameters.
 
 getOptionsOOUI ()
 Get options and make them into arrays suitable for OOUI.
 
 getRaw ( $value)
 Get the complete raw fields for the input, including help text, labels, and whatever.
 
 getTableRow ( $value)
 Get the complete table row for the input, including help text, labels, and whatever.
 
 getTooltipAndAccessKey ()
 Returns the attributes required for the tooltip and accesskey, for Html::element() etc.
 
 getTooltipAndAccessKeyOOUI ()
 Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config.
 
 getVForm ( $value)
 Get the complete field for the input, including help text, labels, and whatever.
 
 hasVisibleOutput ()
 If this field has a user-visible output or not.
 
 isDisabled ( $alldata)
 Test whether this field is supposed to be disabled, based on the values of the other form fields.
 
 isHelpInline ()
 Determine if the help text should be displayed inline.
 
 isHidden ( $alldata)
 Test whether this field is supposed to be hidden, based on the values of the other form fields.
 
 loadDataFromRequest ( $request)
 Get the value that this input has been set to from a posted form, or the input's default value if it has not been set.
 
 msg ( $key,... $params)
 Get a translated interface message.
 
 needsJSForHtml5FormValidation ()
 Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly.
 
 setShowEmptyLabel ( $show)
 Tell the field whether to generate a separate label element if its label is blank.
 
 skipLoadData ( $request)
 Skip this field when collecting data.
 
 validate ( $value, $alldata)
 Override this function to add specific validation checks on the field input.
 

Static Public Member Functions

static flattenOptions ( $options)
 flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>".
 
static forceToStringRecursive ( $array)
 Recursively forces values in an array to strings, because issues arise with integer 0 as a value.
 

Public Attributes

array array[] $mParams
 
HTMLForm null $mParent
 

Protected Member Functions

 checkStateRecurse (array $alldata, array $params)
 Helper function for isHidden and isDisabled to handle recursive data structures.
 
 getClassName ()
 Gets the non namespaced class name.
 
 getFieldLayoutOOUI ( $inputField, $config)
 Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
 
 getLabelAlignOOUI ()
 Get label alignment when generating field for OOUI.
 
 getMessage ( $value)
 Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message.
 
 getNearestField ( $name, $backCompat=false)
 Get the closest field matching a given name.
 
 getNearestFieldByName ( $alldata, $name, $asDisplay=false)
 Fetch a field value from $alldata for the closest field matching a given name.
 
 getNearestFieldValue ( $alldata, $name, $asDisplay=false, $backCompat=false)
 Fetch a field value from $alldata for the closest field matching a given name.
 
 getOOUIModules ()
 Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to infuse this field's OOUI widget.
 
 isSubmitAttempt (WebRequest $request)
 Can we assume that the request is an attempt to submit a HTMLForm, as opposed to an attempt to just view it? This can't normally be distinguished for e.g.
 
 needsLabel ()
 Should this field have a label, or is there no input element with the appropriate id for the label to point to?
 
 parseCondState ( $params)
 Parse the cond-state array to use the field name for submission, since the key in the form descriptor is never known in HTML.
 
 parseCondStateForClient ()
 Parse the cond-state array for client-side.
 
 shouldInfuseOOUI ()
 Whether the field should be automatically infused.
 
 validateCondState ( $params)
 Validate the cond-state params, the existence check of fields should be done later.
 

Static Protected Member Functions

static formatErrors ( $errors)
 Formats one or more errors as accepted by field validation-callback.
 

Protected Attributes

string $mClass = ''
 
array $mCondState = []
 Array to hold params for 'hide-if' or 'disable-if' statements.
 
array $mCondStateClass = []
 
mixed $mDefault
 
string $mDir
 
string false $mHelpClass = false
 
string $mID
 
string $mLabel
 String label, as HTML.
 
string $mName
 
array null false $mOptions = false
 
bool $mOptionsLabelsNotFromMessage = false
 
bool $mShowEmptyLabels = true
 If true will generate an empty div element with no label.
 
string $mVFormClass = ''
 

Detailed Description

The parent class to generate form fields.

Any field type should be a subclass of this.

Stability: stable
to extend

Definition at line 26 of file HTMLFormField.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ cancelSubmit()

MediaWiki\HTMLForm\HTMLFormField::cancelSubmit ( $value,
$alldata )

Override this function if the control can somehow trigger a form submission that shouldn't actually submit the HTMLForm.

Stability: stable
to override
Since
1.23
Parameters
string | array$valueThe value the field was submitted with
array$alldataThe data collected from the form
Returns
bool True to cancel the submission

Reimplemented in MediaWiki\HTMLForm\Field\HTMLFormFieldCloner.

Definition at line 421 of file HTMLFormField.php.

◆ canDisplayErrors()

MediaWiki\HTMLForm\HTMLFormField::canDisplayErrors ( )

True if this field type is able to display errors; false if validation errors need to be displayed in the main HTMLForm error area.

Stability: stable
to override
Returns
bool

Reimplemented in MediaWiki\HTMLForm\Field\HTMLHiddenField.

Definition at line 123 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\hasVisibleOutput().

◆ checkStateRecurse()

MediaWiki\HTMLForm\HTMLFormField::checkStateRecurse ( array $alldata,
array $params )
protected

Helper function for isHidden and isDisabled to handle recursive data structures.

Parameters
array$alldata
array$params
Returns
bool

Definition at line 303 of file HTMLFormField.php.

References $params, MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse(), and MediaWiki\HTMLForm\HTMLFormField\getNearestFieldValue().

Referenced by MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse(), MediaWiki\HTMLForm\HTMLFormField\isDisabled(), and MediaWiki\HTMLForm\HTMLFormField\isHidden().

◆ filter()

MediaWiki\HTMLForm\HTMLFormField::filter ( $value,
$alldata )
Stability: stable
to override
Parameters
mixed$value
mixed[]$alldata
Returns
mixed

Definition at line 472 of file HTMLFormField.php.

◆ flattenOptions()

◆ forceToStringRecursive()

static MediaWiki\HTMLForm\HTMLFormField::forceToStringRecursive ( $array)
static

Recursively forces values in an array to strings, because issues arise with integer 0 as a value.

Parameters
array | string$array
Returns
array|string

Definition at line 1308 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLMultiSelectField\filterDataForSubmit(), and MediaWiki\HTMLForm\Field\HTMLMultiSelectField\getInputHTML().

◆ formatErrors()

static MediaWiki\HTMLForm\HTMLFormField::formatErrors ( $errors)
staticprotected

Formats one or more errors as accepted by field validation-callback.

Parameters
string | Message | array$errorsArray of strings or Message instances To work around limitations in phan-taint-check the calling class has taintedness disabled. So instead we pretend that this method outputs html, since the result is eventually outputted anyways without escaping and this allows us to verify stuff is safe even though the caller has taintedness cleared.
Returns
string HTML
Since
1.18

Definition at line 1393 of file HTMLFormField.php.

References MediaWiki\Message\Message\parse().

◆ getAttributes()

MediaWiki\HTMLForm\HTMLFormField::getAttributes ( array $list)

Returns the given attributes from the parameters.

Stability: stable
to override
Parameters
array$listList of attributes to get
Returns
array Attributes

Reimplemented in MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField, MediaWiki\HTMLForm\Field\HTMLComboboxField, and MediaWiki\HTMLForm\Field\HTMLDateTimeField.

Definition at line 1250 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLMultiSelectField\formatOptions(), MediaWiki\HTMLForm\Field\HTMLRadioField\formatOptions(), MediaWiki\HTMLForm\Field\HTMLButtonField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLCheckField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLRadioField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLTextField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLButtonField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLCheckField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLCheckMatrix\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLFileField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLFormFieldWithButton\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLTextField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLButtonField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLCheckField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLCheckMatrix\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLFileField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLFormFieldWithButton\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLRadioField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLTextAreaField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLTextField\getInputOOUI(), and MediaWiki\HTMLForm\Field\HTMLToggleSwitchField\getInputOOUI().

◆ getClassName()

MediaWiki\HTMLForm\HTMLFormField::getClassName ( )
protected

◆ getCodex()

◆ getDefault()

◆ getDiv()

◆ getErrorsAndErrorClass()

MediaWiki\HTMLForm\HTMLFormField::getErrorsAndErrorClass ( $value)

Determine form errors to display and their classes.

Since
1.20

phan-taint-check gets confused with returning both classes and errors and thinks double escaping is happening, so specify that return value has no taint.

Parameters
string$valueThe value of the input
Returns
array [ $errors, $errorClass ]

Definition at line 1128 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getCodex(), MediaWiki\HTMLForm\HTMLFormField\getDiv(), MediaWiki\HTMLForm\HTMLFormField\getInline(), MediaWiki\HTMLForm\HTMLFormField\getRaw(), MediaWiki\HTMLForm\Field\HTMLCheckMatrix\getTableRow(), and MediaWiki\HTMLForm\HTMLFormField\getTableRow().

◆ getErrorsRaw()

MediaWiki\HTMLForm\HTMLFormField::getErrorsRaw ( $value)

Determine form errors to display, returning them in an array.

Since
1.26
Parameters
string$valueThe value of the input
Returns
string[] Array of error HTML strings

Definition at line 1145 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ getFieldLayoutOOUI()

MediaWiki\HTMLForm\HTMLFormField::getFieldLayoutOOUI ( $inputField,
$config )
protected

Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.

Parameters
\\OOUI\\Widget$inputField
array$config
Returns
\OOUI\FieldLayout

Reimplemented in MediaWiki\HTMLForm\Field\HTMLSelectNamespaceWithButton, and MediaWiki\HTMLForm\Field\HTMLTextFieldWithButton.

Definition at line 924 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ getHelpText()

◆ getHelpTextHtmlDiv()

MediaWiki\HTMLForm\HTMLFormField::getHelpTextHtmlDiv ( $helptext,
$cssClasses = [] )

◆ getHelpTextHtmlRaw()

MediaWiki\HTMLForm\HTMLFormField::getHelpTextHtmlRaw ( $helptext)

Generate help text HTML formatted for raw output.

Since
1.20
Parameters
string | null$helptext
Returns
string

Definition at line 1062 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlDiv().

Referenced by MediaWiki\HTMLForm\HTMLFormField\getRaw().

◆ getHelpTextHtmlTable()

MediaWiki\HTMLForm\HTMLFormField::getHelpTextHtmlTable ( $helptext)

◆ getInline()

MediaWiki\HTMLForm\HTMLFormField::getInline ( $value)

Get the complete field as an inline element.

Stability: stable
to override
Since
1.25
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML inline element

Definition at line 992 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getErrorsAndErrorClass(), MediaWiki\HTMLForm\HTMLFormField\getHelpText(), MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlDiv(), MediaWiki\HTMLForm\HTMLFormField\getInputHTML(), and MediaWiki\HTMLForm\HTMLFormField\getLabelHtml().

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

◆ getInputCodex()

MediaWiki\HTMLForm\HTMLFormField::getInputCodex ( $value,
$hasErrors )

Same as getInputHTML, but for Codex.

This is called by CodexHTMLForm.

If not overridden, falls back to getInputHTML.

Parameters
string$valueThe value to set the input to
bool$hasErrorsWhether there are validation errors. If set to true, this method should apply a CSS class for the error status (e.g. cdx-text-input–status-error) if the component used supports that.
Returns
string HTML

Reimplemented in MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckField, MediaWiki\HTMLForm\Field\HTMLExpiryField, MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField, MediaWiki\HTMLForm\Field\HTMLRadioField, MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField, MediaWiki\HTMLForm\Field\HTMLSelectField, MediaWiki\HTMLForm\Field\HTMLSelectNamespace, MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField, MediaWiki\HTMLForm\Field\HTMLTextAreaField, MediaWiki\HTMLForm\Field\HTMLTextField, and MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField.

Definition at line 112 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getInputHTML().

Referenced by MediaWiki\HTMLForm\HTMLFormField\getCodex().

◆ getInputHTML()

MediaWiki\HTMLForm\HTMLFormField::getInputHTML ( $value)
abstract

This function must be implemented to return the HTML to generate the input object itself.

It should not implement the surrounding table cells/rows, or labels/help messages.

Parameters
mixed$valueThe value to set the input to; eg a default text for a text input.
Returns
string Valid HTML.

Reimplemented in MediaWiki\HTMLForm\Field\HTMLApiField, MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField, MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckField, MediaWiki\HTMLForm\Field\HTMLCheckMatrix, MediaWiki\HTMLForm\Field\HTMLComboboxField, MediaWiki\HTMLForm\Field\HTMLEditTools, MediaWiki\HTMLForm\Field\HTMLExpiryField, MediaWiki\HTMLForm\Field\HTMLFileField, MediaWiki\HTMLForm\Field\HTMLFormFieldWithButton, MediaWiki\HTMLForm\Field\HTMLHiddenField, MediaWiki\HTMLForm\Field\HTMLInfoField, MediaWiki\HTMLForm\Field\HTMLMultiSelectField, MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField, MediaWiki\HTMLForm\Field\HTMLRadioField, MediaWiki\HTMLForm\Field\HTMLRestrictionsField, MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField, MediaWiki\HTMLForm\Field\HTMLSelectField, MediaWiki\HTMLForm\Field\HTMLSelectNamespace, MediaWiki\HTMLForm\Field\HTMLSelectNamespaceWithButton, MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField, MediaWiki\HTMLForm\Field\HTMLSizeFilterField, MediaWiki\HTMLForm\Field\HTMLTagFilter, MediaWiki\HTMLForm\Field\HTMLTagMultiselectField, MediaWiki\HTMLForm\Field\HTMLTextAreaField, MediaWiki\HTMLForm\Field\HTMLTextField, MediaWiki\HTMLForm\Field\HTMLTextFieldWithButton, MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField, MediaWiki\HTMLForm\Field\HTMLUsersMultiselectField, Licenses, and MediaWiki\HTMLForm\Field\HTMLFormFieldCloner.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getDiv(), MediaWiki\HTMLForm\HTMLFormField\getInline(), MediaWiki\HTMLForm\HTMLFormField\getInputCodex(), MediaWiki\HTMLForm\HTMLFormField\getRaw(), and MediaWiki\HTMLForm\HTMLFormField\getTableRow().

◆ getInputOOUI()

MediaWiki\HTMLForm\HTMLFormField::getInputOOUI ( $value)

Same as getInputHTML, but returns an OOUI object.

Defaults to false, which getOOUI will interpret as "use the HTML version"

Stability: stable
to override
Parameters
string$value
Returns
\OOUI\Widget|string|false

Reimplemented in MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField, MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckField, MediaWiki\HTMLForm\Field\HTMLCheckMatrix, MediaWiki\HTMLForm\Field\HTMLComboboxField, MediaWiki\HTMLForm\Field\HTMLDateTimeField, MediaWiki\HTMLForm\Field\HTMLExpiryField, MediaWiki\HTMLForm\Field\HTMLFileField, MediaWiki\HTMLForm\Field\HTMLFormFieldWithButton, MediaWiki\HTMLForm\Field\HTMLInfoField, MediaWiki\HTMLForm\Field\HTMLMultiSelectField, MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField, MediaWiki\HTMLForm\Field\HTMLRadioField, MediaWiki\HTMLForm\Field\HTMLRestrictionsField, MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField, MediaWiki\HTMLForm\Field\HTMLSelectField, MediaWiki\HTMLForm\Field\HTMLSelectNamespace, MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField, MediaWiki\HTMLForm\Field\HTMLTagFilter, MediaWiki\HTMLForm\Field\HTMLTagMultiselectField, MediaWiki\HTMLForm\Field\HTMLTextAreaField, MediaWiki\HTMLForm\Field\HTMLTextField, MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField, MediaWiki\HTMLForm\Field\HTMLToggleSwitchField, MediaWiki\HTMLForm\Field\HTMLUsersMultiselectField, and MediaWiki\HTMLForm\Field\HTMLFormFieldCloner.

Definition at line 97 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ getLabel()

MediaWiki\HTMLForm\HTMLFormField::getLabel ( )
Stability: stable
to override
Returns
string HTML

Reimplemented in MediaWiki\HTMLForm\Field\HTMLCheckField.

Definition at line 1168 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getCodex(), and MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ getLabelAlignOOUI()

MediaWiki\HTMLForm\HTMLFormField::getLabelAlignOOUI ( )
protected

Get label alignment when generating field for OOUI.

Stability: stable
to override
Returns
string 'left', 'right', 'top' or 'inline'

Reimplemented in MediaWiki\HTMLForm\Field\HTMLCheckField.

Definition at line 914 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ getLabelHtml()

MediaWiki\HTMLForm\HTMLFormField::getLabelHtml ( $cellAttributes = [])

◆ getMessage()

◆ getName()

MediaWiki\HTMLForm\HTMLFormField::getName ( )

Get the field name that will be used for submission.

Since
1.38
Returns
string

Definition at line 163 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\$mName.

◆ getNearestField()

MediaWiki\HTMLForm\HTMLFormField::getNearestField ( $name,
$backCompat = false )
protected

Get the closest field matching a given name.

It can handle array fields like the user would expect. The general algorithm is to look for $name as a sibling of $this, then a sibling of $this's parent, and so on.

Parameters
string$name
bool$backCompatWhether to try striping the 'wp' prefix.
Returns
HTMLFormField

Definition at line 178 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getNearestFieldValue(), and MediaWiki\HTMLForm\HTMLFormField\parseCondState().

◆ getNearestFieldByName()

MediaWiki\HTMLForm\HTMLFormField::getNearestFieldByName ( $alldata,
$name,
$asDisplay = false )
protected

Fetch a field value from $alldata for the closest field matching a given name.

Deprecated
since 1.38 Use getNearestFieldValue() instead.
Parameters
array$alldata
string$name
bool$asDisplay
Returns
string

Definition at line 239 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getNearestFieldValue().

◆ getNearestFieldValue()

MediaWiki\HTMLForm\HTMLFormField::getNearestFieldValue ( $alldata,
$name,
$asDisplay = false,
$backCompat = false )
protected

Fetch a field value from $alldata for the closest field matching a given name.

Parameters
array$alldata
string$name
bool$asDisplayWhether the reverting logic of HTMLCheckField should be ignored.
bool$backCompatWhether to try striping the 'wp' prefix.
Returns
mixed

Definition at line 208 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getNearestField().

Referenced by MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse(), and MediaWiki\HTMLForm\HTMLFormField\getNearestFieldByName().

◆ getOOUI()

◆ getOOUIModules()

◆ getOptions()

MediaWiki\HTMLForm\HTMLFormField::getOptions ( )

Fetch the array of options from the field's parameters.

In order, this checks 'options-messages', 'options', then 'options-message'.

Returns
array|null

Definition at line 1322 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\__construct(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\__construct(), MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\__construct(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\filterDataForSubmit(), MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\getAttributes(), MediaWiki\HTMLForm\Field\HTMLRadioField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\getInputCodex(), MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLComboboxField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLRadioField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLRadioField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\validate(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\validate(), MediaWiki\HTMLForm\Field\HTMLRadioField\validate(), and MediaWiki\HTMLForm\Field\HTMLSelectField\validate().

◆ getOptionsOOUI()

MediaWiki\HTMLForm\HTMLFormField::getOptionsOOUI ( )

Get options and make them into arrays suitable for OOUI.

Stability: stable
to override
Returns
array|null Options for inclusion in a select or whatever.

Reimplemented in MediaWiki\HTMLForm\Field\HTMLMultiSelectField.

Definition at line 1349 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLComboboxField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLSelectField\getInputOOUI(), and MediaWiki\HTMLForm\Field\HTMLSelectOrOtherField\getInputOOUI().

◆ getRaw()

MediaWiki\HTMLForm\HTMLFormField::getRaw ( $value)

Get the complete raw fields for the input, including help text, labels, and whatever.

Stability: stable
to override
Since
1.20
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML table row.

Reimplemented in MediaWiki\HTMLForm\Field\HTMLApiField, MediaWiki\HTMLForm\Field\HTMLEditTools, MediaWiki\HTMLForm\Field\HTMLHiddenField, and MediaWiki\HTMLForm\Field\HTMLInfoField.

Definition at line 962 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getErrorsAndErrorClass(), MediaWiki\HTMLForm\HTMLFormField\getHelpText(), MediaWiki\HTMLForm\HTMLFormField\getHelpTextHtmlRaw(), MediaWiki\HTMLForm\HTMLFormField\getInputHTML(), and MediaWiki\HTMLForm\HTMLFormField\getLabelHtml().

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

◆ getTableRow()

◆ getTooltipAndAccessKey()

◆ getTooltipAndAccessKeyOOUI()

MediaWiki\HTMLForm\HTMLFormField::getTooltipAndAccessKeyOOUI ( )

◆ getVForm()

MediaWiki\HTMLForm\HTMLFormField::getVForm ( $value)

Get the complete field for the input, including help text, labels, and whatever.

Fall back from 'vform' to 'div' when not overridden.

Stability: stable
to override
Since
1.25
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML field.

Definition at line 979 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\getDiv().

Referenced by MediaWiki\HTMLForm\VFormHTMLForm\formatField().

◆ hasVisibleOutput()

MediaWiki\HTMLForm\HTMLFormField::hasVisibleOutput ( )

If this field has a user-visible output or not.

If not, it will not be rendered

Stability: stable
to override
Returns
bool

Reimplemented in MediaWiki\HTMLForm\Field\HTMLApiField, and MediaWiki\HTMLForm\Field\HTMLHiddenField.

Definition at line 153 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\canDisplayErrors().

◆ isDisabled()

MediaWiki\HTMLForm\HTMLFormField::isDisabled ( $alldata)

Test whether this field is supposed to be disabled, based on the values of the other form fields.

Since
1.38
Parameters
array$alldataThe data collected from the form
Returns
bool

Definition at line 403 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse(), and MediaWiki\HTMLForm\HTMLFormField\isHidden().

◆ isHelpInline()

MediaWiki\HTMLForm\HTMLFormField::isHelpInline ( )

Determine if the help text should be displayed inline.

Only applies to OOUI forms.

Since
1.31
Returns
bool

Definition at line 1112 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getOOUI(), and MediaWiki\HTMLForm\HTMLFormField\shouldInfuseOOUI().

◆ isHidden()

MediaWiki\HTMLForm\HTMLFormField::isHidden ( $alldata)

Test whether this field is supposed to be hidden, based on the values of the other form fields.

Since
1.23
Parameters
array$alldataThe data collected from the form
Returns
bool

Definition at line 390 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\checkStateRecurse().

Referenced by MediaWiki\HTMLForm\HTMLFormField\isDisabled(), MediaWiki\HTMLForm\Field\HTMLRestrictionsField\validate(), and MediaWiki\HTMLForm\HTMLFormField\validate().

◆ isSubmitAttempt()

MediaWiki\HTMLForm\HTMLFormField::isSubmitAttempt ( WebRequest $request)
protected

Can we assume that the request is an attempt to submit a HTMLForm, as opposed to an attempt to just view it? This can't normally be distinguished for e.g.

checkboxes.

Returns true if the request was posted and has a field for a CSRF token (wpEditToken), or has a form identifier (wpFormIdentifier).

Todo
Consider moving this to HTMLForm?
Parameters
WebRequest$request
Returns
bool

Definition at line 515 of file HTMLFormField.php.

References MediaWiki\Request\WebRequest\getCheck(), and MediaWiki\Request\WebRequest\wasPosted().

Referenced by MediaWiki\HTMLForm\Field\HTMLCheckField\loadDataFromRequest(), MediaWiki\HTMLForm\Field\HTMLCheckMatrix\loadDataFromRequest(), and MediaWiki\HTMLForm\Field\HTMLMultiSelectField\loadDataFromRequest().

◆ loadDataFromRequest()

◆ msg()

MediaWiki\HTMLForm\HTMLFormField::msg ( $key,
$params )

Get a translated interface message.

This is a wrapper around $this->mParent->msg() if $this->mParent is set and wfMessage() otherwise.

Parameters are the same as wfMessage().

Parameters
string | string[] | MessageSpecifier$key
mixed...$params
Returns
Message

Definition at line 139 of file HTMLFormField.php.

References $params, and wfMessage().

Referenced by MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\__construct(), MediaWiki\HTMLForm\Field\HTMLDateTimeField\__construct(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\__construct(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\__construct(), Licenses\__construct(), MediaWiki\HTMLForm\Field\HTMLEditTools\formatMsg(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\getDefault(), MediaWiki\HTMLForm\Field\HTMLSizeFilterField\getInputHTML(), MediaWiki\HTMLForm\Field\HTMLFormFieldCloner\getInputHTMLForKey(), MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLTagMultiselectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLUsersMultiselectField\getInputOOUI(), MediaWiki\HTMLForm\Field\HTMLRadioField\getOptionDescriptions(), MediaWiki\HTMLForm\Field\HTMLUserTextField\isValidIPRange(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\loadDataFromRequest(), Licenses\makeLines(), Licenses\outputOption(), MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField\validate(), MediaWiki\HTMLForm\Field\HTMLCheckMatrix\validate(), MediaWiki\HTMLForm\Field\HTMLDateTimeField\validate(), MediaWiki\HTMLForm\Field\HTMLFloatField\validate(), MediaWiki\HTMLForm\Field\HTMLIntField\validate(), MediaWiki\HTMLForm\Field\HTMLMultiSelectField\validate(), MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField\validate(), MediaWiki\HTMLForm\Field\HTMLRadioField\validate(), MediaWiki\HTMLForm\Field\HTMLRestrictionsField\validate(), MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField\validate(), MediaWiki\HTMLForm\Field\HTMLSelectField\validate(), MediaWiki\HTMLForm\Field\HTMLTagMultiselectField\validate(), MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField\validate(), MediaWiki\HTMLForm\Field\HTMLTitleTextField\validate(), MediaWiki\HTMLForm\Field\HTMLUsersMultiselectField\validate(), MediaWiki\HTMLForm\Field\HTMLUserTextField\validate(), MediaWiki\HTMLForm\HTMLFormField\validate(), and MediaWiki\HTMLForm\Field\HTMLFormFieldCloner\validate().

◆ needsJSForHtml5FormValidation()

MediaWiki\HTMLForm\HTMLFormField::needsJSForHtml5FormValidation ( )

Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly.

Returns
bool
Since
1.29

Definition at line 1446 of file HTMLFormField.php.

◆ needsLabel()

MediaWiki\HTMLForm\HTMLFormField::needsLabel ( )
protected

Should this field have a label, or is there no input element with the appropriate id for the label to point to?

Stability: stable
to override
Returns
bool True to output a label, false to suppress

Reimplemented in MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckField, MediaWiki\HTMLForm\Field\HTMLFormFieldCloner, MediaWiki\HTMLForm\Field\HTMLInfoField, MediaWiki\HTMLForm\Field\HTMLMultiSelectField, MediaWiki\HTMLForm\Field\HTMLRadioField, and MediaWiki\HTMLForm\Field\HTMLSizeFilterField.

Definition at line 487 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getCodex().

◆ parseCondState()

MediaWiki\HTMLForm\HTMLFormField::parseCondState ( $params)
protected

Parse the cond-state array to use the field name for submission, since the key in the form descriptor is never known in HTML.

Also check for field existence here.

Parameters
array$params
Returns
mixed[]

Definition at line 344 of file HTMLFormField.php.

References $params, MediaWiki\HTMLForm\HTMLFormField\getNearestField(), and MediaWiki\HTMLForm\HTMLFormField\parseCondState().

Referenced by MediaWiki\HTMLForm\HTMLFormField\parseCondState(), and MediaWiki\HTMLForm\HTMLFormField\parseCondStateForClient().

◆ parseCondStateForClient()

◆ setShowEmptyLabel()

MediaWiki\HTMLForm\HTMLFormField::setShowEmptyLabel ( $show)

Tell the field whether to generate a separate label element if its label is blank.

Since
1.22
Parameters
bool$showSet to false to not generate a label.
Returns
void

Definition at line 500 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\Field\HTMLButtonField\__construct().

◆ shouldInfuseOOUI()

◆ skipLoadData()

MediaWiki\HTMLForm\HTMLFormField::skipLoadData ( $request)

Skip this field when collecting data.

Stability: stable
to override
Parameters
WebRequest$request
Returns
bool
Since
1.27

Reimplemented in MediaWiki\HTMLForm\Field\HTMLSubmitField.

Definition at line 1435 of file HTMLFormField.php.

◆ validate()

MediaWiki\HTMLForm\HTMLFormField::validate ( $value,
$alldata )

Override this function to add specific validation checks on the field input.

Don't forget to call parent::validate() to ensure that the user-defined callback mValidationCallback is still run

Stability: stable
to override
Parameters
mixed$valueThe value the field was submitted with
array$alldataThe data collected from the form
Returns
bool|string|Message True on success, or String/Message error to display, or false to fail validation without displaying an error.

Reimplemented in MediaWiki\HTMLForm\Field\HTMLAutoCompleteSelectField, MediaWiki\HTMLForm\Field\HTMLButtonField, MediaWiki\HTMLForm\Field\HTMLCheckMatrix, MediaWiki\HTMLForm\Field\HTMLDateTimeField, MediaWiki\HTMLForm\Field\HTMLFloatField, MediaWiki\HTMLForm\Field\HTMLIntField, MediaWiki\HTMLForm\Field\HTMLMultiSelectField, MediaWiki\HTMLForm\Field\HTMLNamespacesMultiselectField, MediaWiki\HTMLForm\Field\HTMLRadioField, MediaWiki\HTMLForm\Field\HTMLRestrictionsField, MediaWiki\HTMLForm\Field\HTMLSelectAndOtherField, MediaWiki\HTMLForm\Field\HTMLSelectField, MediaWiki\HTMLForm\Field\HTMLSelectLimitField, MediaWiki\HTMLForm\Field\HTMLTagMultiselectField, MediaWiki\HTMLForm\Field\HTMLTimezoneField, MediaWiki\HTMLForm\Field\HTMLTitlesMultiselectField, MediaWiki\HTMLForm\Field\HTMLTitleTextField, MediaWiki\HTMLForm\Field\HTMLUsersMultiselectField, MediaWiki\HTMLForm\Field\HTMLUserTextField, EditWatchlistCheckboxSeriesField, and MediaWiki\HTMLForm\Field\HTMLFormFieldCloner.

Definition at line 437 of file HTMLFormField.php.

References MediaWiki\HTMLForm\HTMLFormField\isHidden(), and MediaWiki\HTMLForm\HTMLFormField\msg().

◆ validateCondState()

MediaWiki\HTMLForm\HTMLFormField::validateCondState ( $params)
protected

Validate the cond-state params, the existence check of fields should be done later.

Parameters
array$params

Definition at line 249 of file HTMLFormField.php.

References $params, and MediaWiki\HTMLForm\HTMLFormField\validateCondState().

Referenced by MediaWiki\HTMLForm\HTMLFormField\__construct(), and MediaWiki\HTMLForm\HTMLFormField\validateCondState().

Member Data Documentation

◆ $mClass

string MediaWiki\HTMLForm\HTMLFormField::$mClass = ''
protected

◆ $mCondState

array MediaWiki\HTMLForm\HTMLFormField::$mCondState = []
protected

Array to hold params for 'hide-if' or 'disable-if' statements.

Definition at line 62 of file HTMLFormField.php.

◆ $mCondStateClass

array MediaWiki\HTMLForm\HTMLFormField::$mCondStateClass = []
protected

◆ $mDefault

mixed MediaWiki\HTMLForm\HTMLFormField::$mDefault
protected

◆ $mDir

◆ $mHelpClass

string false MediaWiki\HTMLForm\HTMLFormField::$mHelpClass = false
protected

◆ $mID

◆ $mLabel

string MediaWiki\HTMLForm\HTMLFormField::$mLabel
protected

String label, as HTML.

Set on construction.

Definition at line 39 of file HTMLFormField.php.

◆ $mName

◆ $mOptions

array null false MediaWiki\HTMLForm\HTMLFormField::$mOptions = false
protected

◆ $mOptionsLabelsNotFromMessage

bool MediaWiki\HTMLForm\HTMLFormField::$mOptionsLabelsNotFromMessage = false
protected

Definition at line 58 of file HTMLFormField.php.

◆ $mParams

array array [] MediaWiki\HTMLForm\HTMLFormField::$mParams

◆ $mParent

HTMLForm null MediaWiki\HTMLForm\HTMLFormField::$mParent

Definition at line 75 of file HTMLFormField.php.

◆ $mShowEmptyLabels

bool MediaWiki\HTMLForm\HTMLFormField::$mShowEmptyLabels = true
protected

If true will generate an empty div element with no label.

Since
1.22

Definition at line 70 of file HTMLFormField.php.

◆ $mVFormClass

string MediaWiki\HTMLForm\HTMLFormField::$mVFormClass = ''
protected

Definition at line 45 of file HTMLFormField.php.

Referenced by MediaWiki\HTMLForm\HTMLFormField\getDiv().


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