MediaWiki master
HTMLFormField Class Reference

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

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

Collaboration diagram for 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.
 
 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)
 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.
 
 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

 $mClass = ''
 
array $mCondState = []
 Array to hold params for 'hide-if' or 'disable-if' statements.
 
 $mCondStateClass = []
 
 $mDefault
 
 $mDir
 
 $mFilterCallback
 
 $mHelpClass = false
 
 $mID
 
 $mLabel
 
 $mName
 
array null false $mOptions = false
 
 $mOptionsLabelsNotFromMessage = false
 
bool $mShowEmptyLabels = true
 If true will generate an empty div element with no label.
 
 $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 14 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.

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

Definition at line 379 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.

Stability: stable
to override
Returns
bool

Reimplemented in HTMLHiddenField.

Definition at line 83 of file HTMLFormField.php.

References hasVisibleOutput().

◆ checkStateRecurse()

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

References checkStateRecurse(), getNearestFieldValue(), and true.

Referenced by checkStateRecurse(), isDisabled(), and isHidden().

◆ filter()

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

Definition at line 430 of file HTMLFormField.php.

◆ flattenOptions()

static HTMLFormField::flattenOptions (   $options)
static

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

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

◆ 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.
Returns
string HTML
Since
1.18

Definition at line 1254 of file HTMLFormField.php.

References Message\parse().

◆ getAttributes()

◆ getClassName()

HTMLFormField::getClassName ( )
protected

Gets the non namespaced class name.

Since
1.36
Returns
string

Definition at line 782 of file HTMLFormField.php.

Referenced by HTMLFormFieldCloner\__construct(), getDiv(), getOOUI(), HTMLCheckMatrix\getTableRow(), and getTableRow().

◆ getDefault()

◆ getDiv()

HTMLFormField::getDiv (   $value)

Get the complete div 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 HTMLApiField, HTMLEditTools, HTMLHiddenField, HTMLInfoField, and HTMLTagFilter.

Definition at line 653 of file HTMLFormField.php.

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

Referenced by HTMLForm\formatField(), 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 ]

Definition at line 1002 of file HTMLFormField.php.

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

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

Reimplemented in HTMLSelectNamespaceWithButton, and HTMLTextFieldWithButton.

Definition at line 802 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getHelpText()

HTMLFormField::getHelpText ( )

Determine the help text to display.

Stability: stable
to override
Since
1.20
Returns
string|null HTML

Definition at line 961 of file HTMLFormField.php.

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

◆ getHelpTextHtmlDiv()

HTMLFormField::getHelpTextHtmlDiv (   $helptext)

Generate help text HTML in div format.

Since
1.20
Parameters
string | null$helptext
Returns
string

Definition at line 914 of file HTMLFormField.php.

References parseCondStateForClient().

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

References parseCondStateForClient().

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

◆ getInline()

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

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

Referenced by HTMLForm\formatField().

◆ getInputHTML()

HTMLFormField::getInputHTML (   $value)
abstract

◆ getInputOOUI()

HTMLFormField::getInputOOUI (   $value)

◆ getLabel()

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

Reimplemented in HTMLCheckField.

Definition at line 1042 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getLabelAlignOOUI()

HTMLFormField::getLabelAlignOOUI ( )
protected

Get label alignment when generating field for OOUI.

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

Reimplemented in HTMLCheckField.

Definition at line 792 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getLabelHtml()

HTMLFormField::getLabelHtml (   $cellAttributes = [])
Stability: stable
to override
Parameters
array$cellAttributes
Returns
string

Reimplemented in UploadSourceField.

Definition at line 1052 of file HTMLFormField.php.

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

◆ getMessage()

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

References Message\newFromSpecifier().

Referenced by HTMLButtonField\__construct(), HTMLAutoCompleteSelectField\__construct(), HTMLFileField\__construct(), HTMLSelectAndOtherField\__construct(), HTMLTextAreaField\__construct(), HTMLTextField\__construct(), __construct(), and HTMLEditTools\formatMsg().

◆ getName()

HTMLFormField::getName ( )

Get the field name that will be used for submission.

Since
1.38
Returns
string

Definition at line 123 of file HTMLFormField.php.

◆ getNearestField()

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
mixed

Definition at line 138 of file HTMLFormField.php.

Referenced by getNearestFieldValue(), and parseCondState().

◆ getNearestFieldByName()

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

References getNearestFieldValue().

◆ getNearestFieldValue()

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

References getNearestField().

Referenced by checkStateRecurse(), and getNearestFieldByName().

◆ getOOUI()

HTMLFormField::getOOUI (   $value)

Get the OOUI version of the div.

Falls back to getDiv by default.

Stability: stable
to override
Since
1.26
Parameters
string$valueThe value to set the input to.
Returns
OOUI\FieldLayout

Reimplemented in HTMLInfoField, and HTMLTagFilter.

Definition at line 702 of file HTMLFormField.php.

References getClassName(), getDiv(), getErrorsRaw(), getFieldLayoutOOUI(), getHelpText(), getInputOOUI(), getLabel(), getLabelAlignOOUI(), getOOUIModules(), isHelpInline(), parseCondStateForClient(), and shouldInfuseOOUI().

Referenced by OOUIHTMLForm\formatField().

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

Stability: stable
to override
Returns
string[]

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

Definition at line 826 of file HTMLFormField.php.

Referenced by getOOUI().

◆ getOptions()

◆ getOptionsOOUI()

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

Definition at line 1210 of file HTMLFormField.php.

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

◆ getRaw()

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 HTMLApiField, HTMLEditTools, HTMLHiddenField, and HTMLInfoField.

Definition at line 840 of file HTMLFormField.php.

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

Referenced by HTMLForm\formatField().

◆ getTableRow()

HTMLFormField::getTableRow (   $value)

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

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

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

Definition at line 595 of file HTMLFormField.php.

References getClassName(), getErrorsAndErrorClass(), getHelpText(), getHelpTextHtmlTable(), getInputHTML(), getLabelHtml(), and parseCondStateForClient().

Referenced by HTMLForm\formatField().

◆ getTooltipAndAccessKey()

HTMLFormField::getTooltipAndAccessKey ( )

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

Returns
array Attributes

Definition at line 1093 of file HTMLFormField.php.

Referenced by HTMLCheckField\getInputHTML(), HTMLFileField\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 1106 of file HTMLFormField.php.

Referenced by HTMLCheckField\getInputOOUI(), HTMLFileField\getInputOOUI(), HTMLTextAreaField\getInputOOUI(), HTMLTextField\getInputOOUI(), and HTMLToggleSwitchField\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.

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

Definition at line 857 of file HTMLFormField.php.

References getDiv().

Referenced by CodexHTMLForm\formatField(), and VFormHTMLForm\formatField().

◆ hasVisibleOutput()

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 HTMLApiField, and HTMLHiddenField.

Definition at line 113 of file HTMLFormField.php.

Referenced by canDisplayErrors().

◆ isDisabled()

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

References checkStateRecurse(), and isHidden().

◆ 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 986 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 348 of file HTMLFormField.php.

References checkStateRecurse().

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

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

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

Referenced by HTMLCheckField\loadDataFromRequest(), HTMLCheckMatrix\loadDataFromRequest(), and HTMLMultiSelectField\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.

Stability: stable
to override
Parameters
WebRequest$request
Returns
mixed The value

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

Definition at line 488 of file HTMLFormField.php.

References getDefault().

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

References wfMessage().

Referenced by HTMLAutoCompleteSelectField\__construct(), HTMLDateTimeField\__construct(), HTMLMultiSelectField\__construct(), HTMLSelectAndOtherField\__construct(), Licenses\__construct(), HTMLEditTools\formatMsg(), HTMLSelectAndOtherField\getDefault(), HTMLSizeFilterField\getInputHTML(), HTMLFormFieldCloner\getInputHTMLForKey(), HTMLNamespacesMultiselectField\getInputOOUI(), HTMLTagMultiselectField\getInputOOUI(), HTMLTitlesMultiselectField\getInputOOUI(), HTMLUsersMultiselectField\getInputOOUI(), HTMLUserTextField\isValidIPRange(), HTMLSelectAndOtherField\loadDataFromRequest(), Licenses\makeLines(), Licenses\outputOption(), HTMLAutoCompleteSelectField\validate(), HTMLCheckMatrix\validate(), HTMLDateTimeField\validate(), HTMLFloatField\validate(), HTMLIntField\validate(), HTMLMultiSelectField\validate(), HTMLNamespacesMultiselectField\validate(), HTMLRadioField\validate(), HTMLRestrictionsField\validate(), HTMLSelectAndOtherField\validate(), HTMLSelectField\validate(), HTMLTagMultiselectField\validate(), HTMLTitlesMultiselectField\validate(), HTMLTitleTextField\validate(), HTMLUsersMultiselectField\validate(), HTMLUserTextField\validate(), validate(), and HTMLFormFieldCloner\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 1307 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?

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

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

Definition at line 445 of file HTMLFormField.php.

◆ parseCondState()

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

References getNearestField(), and parseCondState().

Referenced by parseCondState(), and parseCondStateForClient().

◆ parseCondStateForClient()

HTMLFormField::parseCondStateForClient ( )
protected

Parse the cond-state array for client-side.

Returns
array[]

Definition at line 332 of file HTMLFormField.php.

References parseCondState().

Referenced by getDiv(), getHelpTextHtmlDiv(), getHelpTextHtmlTable(), getOOUI(), and getTableRow().

◆ 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 458 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.

Stability: stable
to override
Returns
bool

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

Definition at line 814 of file HTMLFormField.php.

References isHelpInline().

Referenced by getOOUI().

◆ skipLoadData()

HTMLFormField::skipLoadData (   $request)

Skip this field when collecting data.

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

Reimplemented in HTMLSubmitField.

Definition at line 1296 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

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

Definition at line 395 of file HTMLFormField.php.

References isHidden(), msg(), and true.

Referenced by EditWatchlistCheckboxSeriesField\validate().

◆ validateCondState()

HTMLFormField::validateCondState (   $params)
protected

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

Parameters
array$params

Definition at line 207 of file HTMLFormField.php.

References validateCondState().

Referenced by __construct(), and validateCondState().

Member Data Documentation

◆ $mClass

◆ $mCondState

array HTMLFormField::$mCondState = []
protected

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

Definition at line 39 of file HTMLFormField.php.

◆ $mCondStateClass

HTMLFormField::$mCondStateClass = []
protected

Definition at line 40 of file HTMLFormField.php.

◆ $mDefault

HTMLFormField::$mDefault
protected

Definition at line 28 of file HTMLFormField.php.

◆ $mDir

◆ $mFilterCallback

HTMLFormField::$mFilterCallback
protected

Definition at line 20 of file HTMLFormField.php.

◆ $mHelpClass

HTMLFormField::$mHelpClass = false
protected

Definition at line 27 of file HTMLFormField.php.

◆ $mID

◆ $mLabel

HTMLFormField::$mLabel
protected

Definition at line 23 of file HTMLFormField.php.

◆ $mName

◆ $mOptions

array null false HTMLFormField::$mOptions = false
protected

◆ $mOptionsLabelsNotFromMessage

HTMLFormField::$mOptionsLabelsNotFromMessage = false
protected

Definition at line 35 of file HTMLFormField.php.

◆ $mParams

array array [] HTMLFormField::$mParams

Definition at line 16 of file HTMLFormField.php.

Referenced by HTMLExpiryField\getFieldByType().

◆ $mParent

HTMLForm null HTMLFormField::$mParent

Definition at line 51 of file HTMLFormField.php.

◆ $mShowEmptyLabels

bool HTMLFormField::$mShowEmptyLabels = true
protected

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

Since
1.22

Definition at line 46 of file HTMLFormField.php.

◆ $mVFormClass

HTMLFormField::$mVFormClass = ''
protected

Definition at line 26 of file HTMLFormField.php.


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