MediaWiki  master
HTMLFormField Class Reference

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

Inheritance diagram for HTMLFormField:
Collaboration diagram for HTMLFormField:

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

array array[] $mParams
 
HTMLForm null $mParent
 

Protected Member Functions

 getFieldLayoutOOUI ( $inputField, $config)
 Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output. More...
 
 getLabelAlignOOUI ()
 Get label alignment when generating field for OOUI. More...
 
 getMessage ( $value)
 Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message. More...
 
 getNearestFieldByName ( $alldata, $name)
 Fetch a field value from $alldata for the closest field matching a given name. More...
 
 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. More...
 
 isHiddenRecurse (array $alldata, array $params)
 Helper function for isHidden to handle recursive data structures. More...
 
 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. More...
 
 needsLabel ()
 Should this field have a label, or is there no input element with the appropriate id for the label to point to? Stable to override. More...
 
 shouldInfuseOOUI ()
 Whether the field should be automatically infused. More...
 

Static Protected Member Functions

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

Protected Attributes

 $mClass = ''
 
 $mDefault
 
 $mDir
 
 $mFilterCallback
 
 $mHelpClass = false
 
 $mHideIf = null
 
 $mID
 
 $mLabel
 
 $mName
 
array bool null $mOptions = false
 
 $mOptionsLabelsNotFromMessage = false
 
bool $mShowEmptyLabels = true
 If true will generate an empty div element with no label. More...
 
 $mValidationCallback
 
 $mVFormClass = ''
 

Private Member Functions

 lookupOptionsKeys ( $options)
 Given an array of msg-key => value mappings, returns an array with keys being the message texts. More...
 

Detailed Description

The parent class to generate form fields.

Any field type should be a subclass of this.

Stable to extend

Definition at line 9 of file HTMLFormField.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLFormField::__construct (   $params)

Member Function Documentation

◆ cancelSubmit()

HTMLFormField::cancelSubmit (   $value,
  $alldata 
)

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

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 HTMLFormFieldCloner.

Definition at line 293 of file HTMLFormField.php.

◆ canDisplayErrors()

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.

Stable to override

Returns
bool

Reimplemented in HTMLHiddenField.

Definition at line 71 of file HTMLFormField.php.

References hasVisibleOutput().

◆ filter()

HTMLFormField::filter (   $value,
  $alldata 
)

Stable to override.

Parameters
mixed$value
HTMLFormField[]$alldata
Returns
mixed

Definition at line 336 of file HTMLFormField.php.

References $mFilterCallback.

◆ flattenOptions()

◆ forceToStringRecursive()

static 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 1081 of file HTMLFormField.php.

Referenced by HTMLMultiSelectField\filterDataForSubmit(), HTMLMultiSelectField\getInputHTML(), and getOptions().

◆ formatErrors()

static 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.
-taint$errorsexec_html
Returns
string HTML
Since
1.18

Definition at line 1162 of file HTMLFormField.php.

References $lines, and Html\rawElement().

Referenced by getErrorsAndErrorClass().

◆ getAttributes()

◆ getDefault()

◆ getDiv()

HTMLFormField::getDiv (   $value)

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

Stable to override

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

Reimplemented in HTMLInfoField, HTMLHiddenField, HTMLEditTools, HTMLTagFilter, and HTMLApiField.

Definition at line 553 of file HTMLFormField.php.

References $mClass, $mVFormClass, FormatJson\encode(), getErrorsAndErrorClass(), getHelpText(), getHelpTextHtmlDiv(), getInputHTML(), getLabelHtml(), and Html\rawElement().

Referenced by getOOUI(), and getVForm().

◆ getErrorsAndErrorClass()

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 ]
-taint none

Definition at line 903 of file HTMLFormField.php.

References formatErrors(), and validate().

Referenced by getDiv(), getInline(), getRaw(), HTMLCheckMatrix\getTableRow(), and getTableRow().

◆ getErrorsRaw()

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 924 of file HTMLFormField.php.

References validate().

Referenced by getOOUI().

◆ getFieldLayoutOOUI()

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|OOUI\ActionFieldLayout PhanUndeclaredProperty Only some subclasses declare mClassWithButton

Definition at line 685 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getHelpText()

HTMLFormField::getHelpText ( )

Determine the help text to display Stable to override.

Since
1.20
Returns
string|null HTML

Reimplemented in HTMLRestrictionsField.

Definition at line 852 of file HTMLFormField.php.

References getMessage(), and msg().

Referenced by getDiv(), getInline(), getOOUI(), getRaw(), HTMLCheckMatrix\getTableRow(), getTableRow(), and shouldInfuseOOUI().

◆ getHelpTextHtmlDiv()

HTMLFormField::getHelpTextHtmlDiv (   $helptext)

Generate help text HTML in div format.

Since
1.20
Parameters
string | null$helptext
Returns
string

Definition at line 815 of file HTMLFormField.php.

References FormatJson\encode(), and Html\rawElement().

Referenced by getDiv(), getHelpTextHtmlRaw(), and getInline().

◆ getHelpTextHtmlRaw()

HTMLFormField::getHelpTextHtmlRaw (   $helptext)

Generate help text HTML formatted for raw output.

Since
1.20
Parameters
string | null$helptext
Returns
string

Definition at line 842 of file HTMLFormField.php.

References getHelpTextHtmlDiv().

Referenced by getRaw().

◆ getHelpTextHtmlTable()

HTMLFormField::getHelpTextHtmlTable (   $helptext)

Generate help text HTML in table format.

Since
1.20
Parameters
string | null$helptext
Returns
string

Definition at line 786 of file HTMLFormField.php.

References $mHelpClass, FormatJson\encode(), and Html\rawElement().

Referenced by HTMLCheckMatrix\getTableRow(), and getTableRow().

◆ getInline()

HTMLFormField::getInline (   $value)

Get the complete field as an inline element.

Stable to override

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

Definition at line 764 of file HTMLFormField.php.

References getErrorsAndErrorClass(), getHelpText(), getHelpTextHtmlDiv(), getInputHTML(), and getLabelHtml().

◆ getInputHTML()

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 HTMLFormFieldCloner, Licenses, HTMLAutoCompleteSelectField, HTMLRestrictionsField, HTMLCheckMatrix, HTMLTextField, HTMLTitlesMultiselectField, HTMLMultiSelectField, HTMLButtonField, HTMLNamespacesMultiselectField, HTMLHiddenField, HTMLTextAreaField, HTMLUsersMultiselectField, HTMLRadioField, HTMLFormFieldWithButton, HTMLSelectAndOtherField, HTMLInfoField, HTMLTagFilter, HTMLExpiryField, HTMLSelectField, HTMLComboboxField, HTMLSelectNamespace, HTMLSelectOrOtherField, HTMLSelectNamespaceWithButton, HTMLTextFieldWithButton, HTMLSizeFilterField, HTMLApiField, HTMLCheckField, and HTMLEditTools.

Referenced by getDiv(), getInline(), getRaw(), and getTableRow().

◆ getInputOOUI()

HTMLFormField::getInputOOUI (   $value)

◆ getLabel()

HTMLFormField::getLabel ( )

Stable to override.

Returns
string HTML

Reimplemented in HTMLCheckField.

Definition at line 947 of file HTMLFormField.php.

Referenced by getLabelHtml(), and getOOUI().

◆ getLabelAlignOOUI()

HTMLFormField::getLabelAlignOOUI ( )
protected

Get label alignment when generating field for OOUI.

Stable to override

Returns
string 'left', 'right', 'top' or 'inline'

Reimplemented in HTMLCheckField.

Definition at line 674 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getLabelHtml()

HTMLFormField::getLabelHtml (   $cellAttributes = [])

Stable to override.

Parameters
array$cellAttributes
Returns
string

Reimplemented in UploadSourceField.

Definition at line 957 of file HTMLFormField.php.

References $mID, getLabel(), needsLabel(), and Html\rawElement().

Referenced by getDiv(), getInline(), getRaw(), HTMLCheckMatrix\getTableRow(), and getTableRow().

◆ getMessage()

HTMLFormField::getMessage (   $value)
protected

◆ getNearestFieldByName()

HTMLFormField::getNearestFieldByName (   $alldata,
  $name 
)
protected

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

This is complex because it needs to 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. Keeping in mind that $name itself might be referencing an array.

Parameters
array$alldata
string$name
Returns
string

Definition at line 118 of file HTMLFormField.php.

References $keys, and $mName.

Referenced by isHiddenRecurse().

◆ getOOUI()

HTMLFormField::getOOUI (   $value)

Get the OOUI version of the div.

Falls back to getDiv by default. Stable to override

Since
1.26
Parameters
string$valueThe value to set the input to.
Returns
OOUI\FieldLayout|OOUI\ActionFieldLayout

Reimplemented in HTMLInfoField, and HTMLTagFilter.

Definition at line 603 of file HTMLFormField.php.

References $help, $mClass, $mHideIf, getDiv(), getErrorsRaw(), getFieldLayoutOOUI(), getHelpText(), getInputOOUI(), getLabel(), getLabelAlignOOUI(), getOOUIModules(), isHelpInline(), and shouldInfuseOOUI().

◆ getOOUIModules()

HTMLFormField::getOOUIModules ( )
protected

Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to infuse this field's OOUI widget.

Stable to override

Returns
string[]

Reimplemented in HTMLCheckMatrix, HTMLDateTimeField, HTMLTitlesMultiselectField, HTMLUsersMultiselectField, HTMLUserTextField, HTMLNamespacesMultiselectField, HTMLTitleTextField, HTMLSelectAndOtherField, HTMLSelectOrOtherField, HTMLSizeFilterField, HTMLSelectNamespace, and HTMLExpiryField.

Definition at line 713 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getOptions()

◆ getOptionsOOUI()

HTMLFormField::getOptionsOOUI ( )

Get options and make them into arrays suitable for OOUI.

Stable to override

Returns
array Options for inclusion in a select or whatever.

Reimplemented in HTMLMultiSelectField.

Definition at line 1118 of file HTMLFormField.php.

References getOptions(), and Xml\listDropDownOptionsOoui().

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

◆ getRaw()

HTMLFormField::getRaw (   $value)

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

Stable to override

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

Reimplemented in HTMLInfoField, HTMLHiddenField, HTMLEditTools, and HTMLApiField.

Definition at line 727 of file HTMLFormField.php.

References getErrorsAndErrorClass(), getHelpText(), getHelpTextHtmlRaw(), getInputHTML(), and getLabelHtml().

◆ getTableRow()

HTMLFormField::getTableRow (   $value)

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

Stable to override

Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML table row.

Reimplemented in HTMLCheckMatrix, HTMLInfoField, HTMLHiddenField, HTMLEditTools, HTMLTagFilter, and HTMLApiField.

Definition at line 494 of file HTMLFormField.php.

References FormatJson\encode(), getErrorsAndErrorClass(), getHelpText(), getHelpTextHtmlTable(), getInputHTML(), getLabelHtml(), and Html\rawElement().

◆ getTooltipAndAccessKey()

HTMLFormField::getTooltipAndAccessKey ( )

Returns the attributes required for the tooltip and accesskey, for Html::element() etc.

Returns
array Attributes

Definition at line 1008 of file HTMLFormField.php.

References Linker\tooltipAndAccesskeyAttribs().

Referenced by HTMLCheckField\getInputHTML(), HTMLTextAreaField\getInputHTML(), and HTMLTextField\getInputHTML().

◆ getTooltipAndAccessKeyOOUI()

HTMLFormField::getTooltipAndAccessKeyOOUI ( )

Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config.

Returns
array Attributes

Definition at line 1021 of file HTMLFormField.php.

References Linker\accesskey(), and Linker\titleAttrib().

Referenced by HTMLCheckField\getInputOOUI(), HTMLTextAreaField\getInputOOUI(), and HTMLTextField\getInputOOUI().

◆ getVForm()

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.

Stable to override

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

Definition at line 751 of file HTMLFormField.php.

References getDiv().

◆ hasVisibleOutput()

HTMLFormField::hasVisibleOutput ( )

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

If not, it will not be rendered Stable to override

Returns
bool

Reimplemented in HTMLHiddenField, and HTMLApiField.

Definition at line 101 of file HTMLFormField.php.

Referenced by canDisplayErrors().

◆ isHelpInline()

HTMLFormField::isHelpInline ( )

Determine if the help text should be displayed inline.

Only applies to OOUI forms.

Since
1.31
Returns
bool

Definition at line 887 of file HTMLFormField.php.

Referenced by getOOUI(), and shouldInfuseOOUI().

◆ isHidden()

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 274 of file HTMLFormField.php.

References isHiddenRecurse().

Referenced by HTMLRestrictionsField\validate(), and validate().

◆ isHiddenRecurse()

HTMLFormField::isHiddenRecurse ( array  $alldata,
array  $params 
)
protected

Helper function for isHidden to handle recursive data structures.

Parameters
array$alldata
array$params
Returns
bool
Exceptions
MWException

Definition at line 167 of file HTMLFormField.php.

References getNearestFieldByName().

Referenced by isHidden().

◆ isSubmitAttempt()

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 has a field for a CSRF token (wpEditToken) or a form identifier (wpFormIdentifier).

Parameters
WebRequest$request
Returns
bool

Definition at line 378 of file HTMLFormField.php.

References WebRequest\getCheck().

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

◆ loadDataFromRequest()

HTMLFormField::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.

Stable to override

Parameters
WebRequest$request
Returns
mixed The value

Reimplemented in HTMLCheckMatrix, HTMLMultiSelectField, HTMLSelectAndOtherField, HTMLSelectOrOtherField, HTMLFormFieldCloner, HTMLCheckField, HTMLAutoCompleteSelectField, HTMLSizeFilterField, HTMLDateTimeField, HTMLExpiryField, HTMLRestrictionsField, HTMLTitlesMultiselectField, HTMLNamespacesMultiselectField, HTMLUsersMultiselectField, and HTMLSubmitField.

Definition at line 390 of file HTMLFormField.php.

References getDefault().

◆ lookupOptionsKeys()

HTMLFormField::lookupOptionsKeys (   $options)
private

Given an array of msg-key => value mappings, returns an array with keys being the message texts.

It also forces values to strings.

Parameters
array$options
Returns
array

Definition at line 1063 of file HTMLFormField.php.

References msg().

Referenced by getOptions().

◆ msg()

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 87 of file HTMLFormField.php.

References wfMessage().

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

◆ needsJSForHtml5FormValidation()

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 1221 of file HTMLFormField.php.

◆ needsLabel()

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? Stable to override.

Returns
bool True to output a label, false to suppress

Reimplemented in HTMLMultiSelectField, HTMLFormFieldCloner, HTMLButtonField, HTMLInfoField, HTMLCheckField, HTMLRadioField, and HTMLSizeFilterField.

Definition at line 351 of file HTMLFormField.php.

Referenced by getLabelHtml().

◆ setShowEmptyLabel()

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 364 of file HTMLFormField.php.

Referenced by HTMLButtonField\__construct().

◆ shouldInfuseOOUI()

HTMLFormField::shouldInfuseOOUI ( )
protected

Whether the field should be automatically infused.

Note that all OOUI HTMLForm fields are infusable (you can call OO.ui.infuse() on them), but not all are infused by default, since there is no benefit in doing it e.g. for buttons and it's a small performance hit on page load. Stable to override

Returns
bool

Reimplemented in HTMLCheckMatrix, HTMLDateTimeField, HTMLTitlesMultiselectField, HTMLUsersMultiselectField, HTMLUserTextField, HTMLNamespacesMultiselectField, HTMLSelectField, HTMLTitleTextField, HTMLSelectOrOtherField, HTMLSelectNamespace, HTMLComboboxField, and HTMLExpiryField.

Definition at line 701 of file HTMLFormField.php.

References getHelpText(), and isHelpInline().

Referenced by getOOUI().

◆ skipLoadData()

HTMLFormField::skipLoadData (   $request)

Skip this field when collecting data.

Stable to override

Parameters
WebRequest$request
Returns
bool
Since
1.27

Reimplemented in HTMLSubmitField.

Definition at line 1210 of file HTMLFormField.php.

◆ validate()

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 Stable to override

Parameters
string | array$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 HTMLFormFieldCloner, HTMLSelectAndOtherField, HTMLButtonField, HTMLAutoCompleteSelectField, HTMLDateTimeField, HTMLRestrictionsField, HTMLTitlesMultiselectField, HTMLCheckMatrix, HTMLMultiSelectField, HTMLUserTextField, HTMLTitleTextField, EditWatchlistCheckboxSeriesField, HTMLNamespacesMultiselectField, HTMLUsersMultiselectField, HTMLRadioField, HTMLSelectLimitField, HTMLIntField, HTMLSelectField, and HTMLFloatField.

Definition at line 309 of file HTMLFormField.php.

References $mParent, isHidden(), and msg().

Referenced by getErrorsAndErrorClass(), getErrorsRaw(), and EditWatchlistCheckboxSeriesField\validate().

Member Data Documentation

◆ $mClass

◆ $mDefault

HTMLFormField::$mDefault
protected

Definition at line 22 of file HTMLFormField.php.

Referenced by HTMLHiddenField\getHiddenFieldData().

◆ $mDir

◆ $mFilterCallback

HTMLFormField::$mFilterCallback
protected

Definition at line 14 of file HTMLFormField.php.

Referenced by filter().

◆ $mHelpClass

HTMLFormField::$mHelpClass = false
protected

Definition at line 21 of file HTMLFormField.php.

Referenced by getHelpTextHtmlTable().

◆ $mHideIf

HTMLFormField::$mHideIf = null
protected

Definition at line 28 of file HTMLFormField.php.

Referenced by HTMLFormFieldCloner\createFieldsForKey(), and getOOUI().

◆ $mID

◆ $mLabel

HTMLFormField::$mLabel
protected

Definition at line 17 of file HTMLFormField.php.

Referenced by HTMLCheckField\getLabel().

◆ $mName

◆ $mOptions

array bool null HTMLFormField::$mOptions = false
protected

◆ $mOptionsLabelsNotFromMessage

HTMLFormField::$mOptionsLabelsNotFromMessage = false
protected

Definition at line 27 of file HTMLFormField.php.

◆ $mParams

array array [] HTMLFormField::$mParams

Definition at line 11 of file HTMLFormField.php.

Referenced by HTMLExpiryField\getFieldByType().

◆ $mParent

HTMLForm null HTMLFormField::$mParent

Definition at line 39 of file HTMLFormField.php.

Referenced by validate().

◆ $mShowEmptyLabels

bool HTMLFormField::$mShowEmptyLabels = true
protected

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

Since
1.22

Definition at line 34 of file HTMLFormField.php.

◆ $mValidationCallback

HTMLFormField::$mValidationCallback
protected

Definition at line 13 of file HTMLFormField.php.

◆ $mVFormClass

HTMLFormField::$mVFormClass = ''
protected

Definition at line 20 of file HTMLFormField.php.

Referenced by getDiv().


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