5use InvalidArgumentException;
32protected $mValidationCallback;
34protected $mFilterCallback;
114// If not overridden, fall back to getInputHTML() 142publicfunctionmsg( $key, ...$params ) {
143if ( $this->mParent ) {
144return $this->mParent->msg( $key, ...$params );
182// When the field is belong to a HTMLFormFieldCloner 183 $cloner = $this->mParams[
'cloner'] ??
null;
185 $field = $cloner->findNearestField( $this, $name );
191if ( $backCompat && str_starts_with( $name,
'wp' ) &&
192 !$this->mParent->hasField( $name )
194// Don't break the existed use cases. 195return $this->mParent->getField( substr( $name, 2 ) );
197return $this->mParent->getField( $name );
213// When the field belongs to a HTMLFormFieldCloner 214 $cloner = $field->mParams[
'cloner'] ??
null;
216 $value = $cloner->extractFieldData( $field, $alldata );
218// Note $alldata is an empty array when first rendering a form with a formIdentifier. 219// In that case, $alldata[$field->mParams['fieldname']] is unset and we use the 220// field's default value 221 $value = $alldata[$field->mParams[
'fieldname']] ?? $field->getDefault();
224// Check invert state for HTMLCheckField 225if ( $asDisplay && $field instanceof
HTMLCheckField && ( $field->mParams[
'invert'] ??
false ) ) {
253 $origParams = $params;
254 $op = array_shift( $params );
256 $makeException =
function (
string $details ) use ( $origParams ): InvalidArgumentException {
257returnnew InvalidArgumentException(
258"Invalid hide-if or disable-if specification for $this->mName: " .
259 $details .
" in " . var_export( $origParams,
true )
265if ( count( $params ) !== 1 ) {
266throw $makeException(
"NOT takes exactly one parameter" );
268// Fall-through intentionally 274foreach ( $params as $i => $p ) {
275if ( !is_array( $p ) ) {
276 $type = get_debug_type( $p );
277throw $makeException(
"Expected array, found $type at index $i" );
286if ( count( $params ) !== 2 ) {
287throw $makeException(
"$op takes exactly two parameters" );
289 [ $name, $value ] = $params;
290if ( !is_string( $name ) || !is_string( $value ) ) {
291throw $makeException(
"Parameters for $op must be strings" );
296throw $makeException(
"Unknown operation" );
308 $op = array_shift( $params );
309 $valueChk = [
'AND' =>
false,
'OR' =>
true,
'NAND' =>
false,
'NOR' => true ];
310 $valueRet = [
'AND' =>
true,
'OR' =>
false,
'NAND' =>
false,
'NOR' => true ];
317foreach ( $params as $p ) {
319return !$valueRet[$op];
322return $valueRet[$op];
330 [ $field, $value ] = $params;
334return ( $value === (
string)$testValue );
336return ( $value !== (
string)$testValue );
338return in_array( $value, $testValue,
true );
352 $op = array_shift( $params );
360foreach ( $params as $p ) {
371 [ $name, $value ] = $params;
373return [ $op, $field->getName(), $value ];
384foreach ( $this->mCondState as $type => $params ) {
399return isset( $this->mCondState[
'hide'] ) &&
412return ( $this->mParams[
'disabled'] ??
false ) ||
414 ( isset( $this->mCondState[
'disable'] )
450if ( isset( $this->mParams[
'required'] )
451 && $this->mParams[
'required'] !==
false 452 && ( $value ===
'' || $value ===
false || $value ===
null )
454return $this->
msg(
'htmlform-required' );
457if ( $this->mValidationCallback ===
null ) {
461 $p = ( $this->mValidationCallback )( $value, $alldata, $this->mParent );
464 $language = $this->mParent ? $this->mParent->getLanguage() : RequestContext::getMain()->getLanguage();
466return $p->isGood() ? true : Status::wrap( $p )->getHTML(
false,
false, $language );
480publicfunctionfilter( $value, $alldata ) {
481if ( $this->mFilterCallback !==
null ) {
482 $value = ( $this->mFilterCallback )( $value, $alldata, $this->mParent );
509 $this->mShowEmptyLabels = $show;
524// HTMLForm would add a hidden field of edit token for forms that require to be posted. 526// The identifier matching or not has been checked in HTMLForm::prepareForm() 527 || $request->
getCheck(
'wpFormIdentifier' );
539if ( $request->getCheck( $this->mName ) ) {
540return $request->getText( $this->mName );
555 $this->mParams = $params;
557if ( isset( $params[
'parent'] ) && $params[
'parent'] instanceof
HTMLForm ) {
558 $this->mParent = $params[
'parent'];
560// Normally parent is added automatically by HTMLForm::factory. 561// Several field types already assume unconditionally this is always set, 562// so deprecate manually creating an HTMLFormField without a parent form set. 564 __METHOD__ .
": Constructing an HTMLFormField without a 'parent' parameter",
569 # Generate the label from a message, if possible 570if ( isset( $params[
'label-message'] ) ) {
571 $this->mLabel = $this->
getMessage( $params[
'label-message'] )->parse();
572 } elseif ( isset( $params[
'label'] ) ) {
573if ( $params[
'label'] ===
' ' || $params[
'label'] ===
"\u{00A0}" ) {
574// Apparently some things set   directly and in an odd format 575 $this->mLabel =
"\u{00A0}";
577 $this->mLabel = htmlspecialchars( $params[
'label'] );
579 } elseif ( isset( $params[
'label-raw'] ) ) {
580 $this->mLabel = $params[
'label-raw'];
583 $this->mName = $params[
'name'] ??
'wp' . $params[
'fieldname'];
585if ( isset( $params[
'dir'] ) ) {
586 $this->mDir = $params[
'dir'];
589 $this->mID =
"mw-input-{$this->mName}";
591if ( isset( $params[
'default'] ) ) {
592 $this->mDefault = $params[
'default'];
595if ( isset( $params[
'id'] ) ) {
596 $this->mID = $params[
'id'];
599if ( isset( $params[
'cssclass'] ) ) {
600 $this->mClass = $params[
'cssclass'];
603if ( isset( $params[
'csshelpclass'] ) ) {
604 $this->mHelpClass = $params[
'csshelpclass'];
607if ( isset( $params[
'validation-callback'] ) ) {
608 $this->mValidationCallback = $params[
'validation-callback'];
611if ( isset( $params[
'filter-callback'] ) ) {
612 $this->mFilterCallback = $params[
'filter-callback'];
615if ( isset( $params[
'hidelabel'] ) ) {
616 $this->mShowEmptyLabels =
false;
618if ( isset( $params[
'notices'] ) ) {
619 $this->mNotices = $params[
'notices'];
622if ( isset( $params[
'hide-if'] ) && $params[
'hide-if'] ) {
624 $this->mCondState[
'hide'] = $params[
'hide-if'];
625 $this->mCondStateClass[] =
'mw-htmlform-hide-if';
627if ( !( isset( $params[
'disabled'] ) && $params[
'disabled'] ) &&
628 isset( $params[
'disable-if'] ) && $params[
'disable-if']
631 $this->mCondState[
'disable'] = $params[
'disable-if'];
632 $this->mCondStateClass[] =
'mw-htmlform-disable-if';
650 $cellAttributes = [];
654if ( !empty( $this->mParams[
'vertical-label'] ) ) {
655 $cellAttributes[
'colspan'] = 2;
656 $verticalLabel =
true;
658 $verticalLabel =
false;
663 $field = Html::rawElement(
665 [
'class' =>
'mw-input' ] + $cellAttributes,
666 $inputHtml .
"\n$errors" 669if ( $this->mCondState ) {
671 $rowClasses .= implode(
' ', $this->mCondStateClass );
672if ( $this->
isHidden( $this->mParent->mFieldData ) ) {
673 $rowClasses .=
' mw-htmlform-hide-if-hidden';
677if ( $verticalLabel ) {
678 $html = Html::rawElement(
'tr',
679 $rowAttributes + [
'class' =>
"mw-htmlform-vertical-label $rowClasses" ], $label );
680 $html .= Html::rawElement(
'tr',
682'class' =>
"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses" 686 $html = Html::rawElement(
'tr',
688'class' =>
"mw-htmlform-field-$fieldType {$this->mClass} $errorClass $rowClasses" 693return $html . $helptext;
711 $cellAttributes = [];
716'mw-htmlform-nolabel' => ( $label ===
'' )
719 $horizontalLabel = $this->mParams[
'horizontal-label'] ??
false;
721if ( $horizontalLabel ) {
722 $field =
"\u{00A0}" . $inputHtml .
"\n$errors";
724 $field = Html::rawElement(
726// @phan-suppress-next-line PhanUselessBinaryAddRight 727 [
'class' => $outerDivClass ] + $cellAttributes,
728 $inputHtml .
"\n$errors" 732 $wrapperAttributes = [
'class' => [
733"mw-htmlform-field-$fieldType",
738if ( $this->mCondState ) {
740 $wrapperAttributes[
'class'] = array_merge( $wrapperAttributes[
'class'], $this->mCondStateClass );
741if ( $this->
isHidden( $this->mParent->mFieldData ) ) {
742 $wrapperAttributes[
'class'][] =
'mw-htmlform-hide-if-hidden';
745return Html::rawElement(
'div', $wrapperAttributes, $label . $field ) .
762// This field doesn't have an OOUI implementation yet at all. Fall back to getDiv() to 763// generate the whole field, label and errors and all, then wrap it in a Widget. 764// It might look weird, but it'll work OK. 766new \OOUI\Widget( [
'content' =>
new \OOUI\HtmlSnippet( $this->
getDiv( $value ) ) ] ),
772if ( is_string( $inputField ) ) {
773// We have an OOUI implementation, but it's not proper, and we got a load of HTML. 774// Cheat a little and wrap it in a widget. It won't be infusable, though, since client-side 775// JavaScript doesn't know how to rebuilt the contents. 776 $inputField = new \OOUI\Widget( [
'content' =>
new \OOUI\HtmlSnippet( $inputField ) ] );
783foreach ( $errors as &$error ) {
784 $error = new \OOUI\HtmlSnippet( $error );
788'classes' => [
"mw-htmlform-field-$fieldType" ],
790'help' => ( $help !==
null && $help !==
'' ) ?
new \OOUI\HtmlSnippet( $help ) :
null,
792'infusable' => $infusable,
794'notices' => $this->mNotices ?: [],
796if ( $this->mClass !==
'' ) {
800 $preloadModules =
false;
803 $preloadModules =
true;
804 $config[
'classes'][] =
'mw-htmlform-autoinfuse';
806if ( $this->mCondState ) {
807 $config[
'classes'] = array_merge( $config[
'classes'], $this->mCondStateClass );
808if ( $this->
isHidden( $this->mParent->mFieldData ) ) {
809 $config[
'classes'][] =
'mw-htmlform-hide-if-hidden';
813// the element could specify, that the label doesn't need to be added 815if ( $label && $label !==
"\u{00A0}" && $label !==
' ' ) {
816 $config[
'label'] = new \OOUI\HtmlSnippet( $label );
819if ( $this->mCondState ) {
820 $preloadModules =
true;
826if ( $preloadModules ) {
827 $this->mParent->getOutput()->addModules(
'mediawiki.htmlform.ooui' );
828 $this->mParent->getOutput()->addModules( $this->
getOOUIModules() );
842 $isDisabled = ( $this->mParams[
'disabled'] ?? false );
846 $labelValue = trim( $this->
getLabel() );
847// For weird historical reasons, a non-breaking space is treated as an empty label 848// Check for both a literal nbsp ("\u{00A0}") and the HTML-encoded version 849if ( $labelValue !==
'' && $labelValue !==
"\u{00A0}" && $labelValue !==
' ' ) {
851 $labelClasses = [
'cdx-label' ];
853 $labelClasses[] =
'cdx-label--disabled';
855// <div class="cdx-label"> 856 $labelDiv = Html::rawElement(
'div', [
'class' => $labelClasses ],
857// <label class="cdx-label__label" for="ID"> 858 Html::rawElement(
'label', [
'class' =>
'cdx-label__label' ] + $labelFor,
859// <span class="cdx-label__label__text"> 860 Html::rawElement(
'span', [
'class' =>
'cdx-label__label__text' ],
868// <div class="cdx-field__help-text"> 872// <div class="cdx-field__validation-message"> 873// $errors is a <div class="cdx-message"> 874// FIXME right now this generates a block message (cdx-message--block), we want an inline message instead 875 $validationMessage =
'';
877if ( $errors !==
'' ) {
878 $validationMessage = Html::rawElement(
'div', [
'class' =>
'cdx-field__validation-message' ],
885// <div class="cdx-field__control cdx-field__control--has-help-text"> 886 $controlClasses = [
'cdx-field__control' ];
888 $controlClasses[] =
'cdx-field__control--has-help-text';
890 $control = Html::rawElement(
'div', [
'class' => $controlClasses ], $inputHtml );
892// <div class="cdx-field"> 894"mw-htmlform-field-{$this->getClassName()}",
900 $fieldClasses[] =
'cdx-field--disabled';
902 $fieldAttributes = [];
903// Set data attribute and CSS class for client side handling of hide-if / disable-if 904if ( $this->mCondState ) {
906 $fieldClasses = array_merge( $fieldClasses, $this->mCondStateClass );
907if ( $this->
isHidden( $this->mParent->mFieldData ) ) {
908 $fieldClasses[] =
'mw-htmlform-hide-if-hidden';
912return Html::rawElement(
'div', [
'class' => $fieldClasses ] + $fieldAttributes,
913 $labelDiv . $control . $helptext . $validationMessage
925 $name = explode(
'\\', static::class );
957// Always infuse fields with popup help text, since the interface for it is nicer with JS 958return !$this->
isHelpInline() && $this->getHelpMessages();
984return"\n" . $errors .
1003 $this->mVFormClass =
' mw-ui-vform-field';
1004return $this->
getDiv( $value );
1016return"\n" . $errors .
1031if ( $helptext ===
null ) {
1035 $rowAttributes = [];
1036if ( $this->mCondState ) {
1041 $tdClasses = [
'htmlform-tip' ];
1042if ( $this->mHelpClass !==
false ) {
1045return Html::rawElement(
'tr', $rowAttributes,
1046 Html::rawElement(
'td', [
'colspan' => 2,
'class' => $tdClasses ], $helptext )
1060if ( $helptext ===
null ) {
1064 $wrapperAttributes = [
1065'class' => array_merge( $cssClasses, [
'htmlform-tip' ] ),
1067if ( $this->mHelpClass !==
false ) {
1070if ( $this->mCondState ) {
1072 $wrapperAttributes[
'class'] = array_merge( $wrapperAttributes[
'class'], $this->mCondStateClass );
1074return Html::rawElement(
'div', $wrapperAttributes, $helptext );
1088privatefunction getHelpMessages(): array {
1089if ( isset( $this->mParams[
'help-message'] ) ) {
1090return [ $this->mParams[
'help-message'] ];
1091 } elseif ( isset( $this->mParams[
'help-messages'] ) ) {
1092return $this->mParams[
'help-messages'];
1093 } elseif ( isset( $this->mParams[
'help-raw'] ) ) {
1094return [
new HtmlArmor( $this->mParams[
'help-raw'] ) ];
1095 } elseif ( isset( $this->mParams[
'help'] ) ) {
1096// @deprecated since 1.43, use 'help-raw' key instead 1097return [
new HtmlArmor( $this->mParams[
'help'] ) ];
1112foreach ( $this->getHelpMessages() as $msg ) {
1114 $html[] = HtmlArmor::getHtml( $msg );
1116 $msg = $this->getMessage( $msg );
1117if ( $msg->exists() ) {
1118 $html[] = $msg->parse();
1123return $html ? implode( $this->msg(
'word-separator' )->escaped(), $html ) :
null;
1135return $this->mParams[
'help-inline'] ??
true;
1151 $errors = $this->validate( $value, $this->mParent->mFieldData );
1153if ( is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
1157return [ self::formatErrors( $errors ),
'mw-htmlform-invalid-input' ];
1168 $errors = $this->validate( $value, $this->mParent->mFieldData );
1170if ( is_bool( $errors ) || !$this->mParent->wasSubmitted() ) {
1174if ( !is_array( $errors ) ) {
1175 $errors = [ $errors ];
1177foreach ( $errors as &$error ) {
1178if ( $error instanceof
Message ) {
1179 $error = $error->parse();
1191return $this->mLabel ??
'';
1201 # Don't output a for= attribute for labels with no associated input. 1202 # Kind of hacky here, possibly we don't want these to be <label>s at all. 1203 $for = $this->needsLabel() ? [
'for' => $this->mID ] : [];
1205 $labelValue = trim( $this->getLabel() );
1206 $hasLabel = $labelValue !==
'' && $labelValue !==
"\u{00A0}" && $labelValue !==
' ';
1208 $displayFormat = $this->mParent->getDisplayFormat();
1209 $horizontalLabel = $this->mParams[
'horizontal-label'] ??
false;
1211if ( $displayFormat ===
'table' ) {
1212return Html::rawElement(
'td',
1213 [
'class' =>
'mw-label' ] + $cellAttributes,
1214 Html::rawElement(
'label', $for, $labelValue ) );
1215 } elseif ( $hasLabel || $this->mShowEmptyLabels ) {
1216if ( $displayFormat ===
'div' && !$horizontalLabel ) {
1217return Html::rawElement(
'div',
1218 [
'class' =>
'mw-label' ] + $cellAttributes,
1219 Html::rawElement(
'label', $for, $labelValue ) );
1221return Html::rawElement(
'label', $for, $labelValue );
1233return $this->mDefault ??
null;
1242if ( empty( $this->mParams[
'tooltip'] ) ) {
1246return Linker::tooltipAndAccesskeyAttribs( $this->mParams[
'tooltip'] );
1255if ( empty( $this->mParams[
'tooltip'] ) ) {
1260'title' => Linker::titleAttrib( $this->mParams[
'tooltip'] ),
1261'accessKey' => Linker::accesskey( $this->mParams[
'tooltip'] ),
1273static $boolAttribs = [
'disabled',
'required',
'autofocus',
'multiple',
'readonly' ];
1276foreach ( $list as $key ) {
1277if ( in_array( $key, $boolAttribs ) ) {
1278if ( !empty( $this->mParams[$key] ) ) {
1281 } elseif ( isset( $this->mParams[$key] ) ) {
1282 $ret[$key] = $this->mParams[$key];
1298privatefunction lookupOptionsKeys( $options, $needsParse ) {
1300foreach ( $options as $key => $value ) {
1301 $msg = $this->msg( $key );
1302 $msgAsText = $needsParse ? $msg->parse() : $msg->plain();
1303if ( array_key_exists( $msgAsText, $ret ) ) {
1304 LoggerFactory::getInstance(
'translation-problem' )->error(
1305'The option that uses the message key {msg_key_one} has the same translation as ' .
1306'another option in {lang}. This means that {msg_key_one} will not be used as an option.',
1308'msg_key_one' => $key,
1309'lang' => $this->mParent ?
1310 $this->mParent->getLanguageCode()->toBcp47Code() :
1316 $ret[$msgAsText] = is_array( $value )
1317 ? $this->lookupOptionsKeys( $value, $needsParse )
1331if ( is_array( $array ) ) {
1332return array_map( self::forceToStringRecursive( ... ), $array );
1334return strval( $array );
1345if ( $this->mOptions ===
false ) {
1346if ( array_key_exists(
'options-messages', $this->mParams ) ) {
1347 $needsParse = $this->mParams[
'options-messages-parse'] ??
false;
1349 $this->mOptionsLabelsNotFromMessage =
true;
1351 $this->mOptions = $this->lookupOptionsKeys( $this->mParams[
'options-messages'], $needsParse );
1352 } elseif ( array_key_exists(
'options', $this->mParams ) ) {
1353 $this->mOptionsLabelsNotFromMessage =
true;
1354 $this->mOptions = self::forceToStringRecursive( $this->mParams[
'options'] );
1355 } elseif ( array_key_exists(
'options-message', $this->mParams ) ) {
1356 $message = $this->getMessage( $this->mParams[
'options-message'] )->inContentLanguage()->plain();
1357 $this->mOptions = Html::listDropdownOptions( $message );
1359 $this->mOptions =
null;
1363return $this->mOptions;
1372 $oldoptions = $this->getOptions();
1374if ( $oldoptions ===
null ) {
1378return Html::listDropdownOptionsOoui( $oldoptions );
1391foreach ( $options as $value ) {
1392if ( is_array( $value ) ) {
1393 $flatOpts = array_merge( $flatOpts, self::flattenOptions( $value ) );
1395 $flatOpts[] = $value;
1416if ( is_array( $errors ) && count( $errors ) === 1 ) {
1417 $errors = array_shift( $errors );
1420if ( is_array( $errors ) ) {
1421foreach ( $errors as &$error ) {
1422 $error = Html::rawElement(
'li', [],
1426 $errors = Html::rawElement(
'ul', [], implode(
"\n", $errors ) );
1427 } elseif ( $errors instanceof
Message ) {
1428 $errors = $errors->parse();
1431return Html::errorBox( $errors );
1443if ( $this->mParent ) {
1444 $message->setContext( $this->mParent );
1458return !empty( $this->mParams[
'nodata'] );
1469// This is probably more restrictive than it needs to be, but better safe than sorry 1470return (
bool)$this->mCondState;
1485return $this->mOptionsLabelsNotFromMessage
1486 ? $label : htmlspecialchars( $label, ENT_NOQUOTES );
1501return $this->mOptionsLabelsNotFromMessage
1502 ? new \OOUI\HtmlSnippet( $label ) : $label;
1507class_alias( HTMLFormField::class,
'HTMLFormField' );
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
Group all the pieces relevant to the context of a request into one instance.
A container for HTMLFormFields that allows for multiple copies of the set of fields to be displayed t...
The parent class to generate form fields.
parseCondStateForClient()
Parse the cond-state array for client-side.
getTooltipAndAccessKey()
Returns the attributes required for the tooltip and accesskey, for Html::element() etc.
getMessage( $value)
Turns a *-message parameter (which could be a MessageSpecifier, or a message name,...
getOptionsOOUI()
Get options and make them into arrays suitable for OOUI.
array $mCondState
Array to hold params for 'hide-if' or 'disable-if' statements.
getOOUI( $value)
Get the OOUI version of the div.
makeLabelSnippet( $label)
The keys in the array returned by getOptions() can be either HTML or plain text depending on $this->m...
getName()
Get the field name that will be used for submission.
getNearestFieldValue( $alldata, $name, $asDisplay=false, $backCompat=false)
Fetch a field value from $alldata for the closest field matching a given name.
getHelpTextHtmlRaw( $helptext)
Generate help text HTML formatted for raw output.
static flattenOptions( $options)
flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>...
getLabelHtml( $cellAttributes=[])
getTooltipAndAccessKeyOOUI()
Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config.
getNearestFieldByName( $alldata, $name, $asDisplay=false)
Fetch a field value from $alldata for the closest field matching a given name.
bool $mShowEmptyLabels
If true will generate an empty div element with no label.
getErrorsAndErrorClass( $value)
Determine form errors to display and their classes.
bool $mOptionsLabelsNotFromMessage
isHidden( $alldata)
Test whether this field is supposed to be hidden, based on the values of the other form fields.
isHelpInline()
Determine if the help text should be displayed inline.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
filter( $value, $alldata)
loadDataFromRequest( $request)
Get the value that this input has been set to from a posted form, or the input's default value if it ...
array null false $mOptions
__construct( $params)
Initialise the object.
getClassName()
Gets the non namespaced class name.
skipLoadData( $request)
Skip this field when collecting data.
static forceToStringRecursive( $array)
Recursively forces values in an array to strings, because issues arise with integer 0 as a value.
hasVisibleOutput()
If this field has a user-visible output or not.
getLabelAlignOOUI()
Get label alignment when generating field for OOUI.
validateCondState( $params)
Validate the cond-state params, the existence check of fields should be done later.
needsLabel()
Should this field have a label, or is there no input element with the appropriate id for the label to...
getOptions()
Fetch the array of options from the field's parameters.
cancelSubmit( $value, $alldata)
Override this function if the control can somehow trigger a form submission that shouldn't actually s...
getDiv( $value)
Get the complete div for the input, including help text, labels, and whatever.
getAttributes(array $list)
Returns the given attributes from the parameters.
getFieldLayoutOOUI( $inputField, $config)
Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
getHelpText()
Determine the help text to display.
getCodex( $value)
Get the Codex version of the div.
parseCondState( $params)
Parse the cond-state array to use the field name for submission, since the key in the form descriptor...
getNearestField( $name, $backCompat=false)
Get the closest field matching a given name.
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
msg( $key,... $params)
Get a translated interface message.
getRaw( $value)
Get the complete raw fields for the input, including help text, labels, and whatever.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
getErrorsRaw( $value)
Determine form errors to display, returning them in an array.
shouldInfuseOOUI()
Whether the field should be automatically infused.
needsJSForHtml5FormValidation()
Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5 form ...
canDisplayErrors()
True if this field type is able to display errors; false if validation errors need to be displayed in...
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.
isSubmitAttempt(WebRequest $request)
Can we assume that the request is an attempt to submit a HTMLForm, as opposed to an attempt to just v...
string $mLabel
String label, as HTML.
getInputCodex( $value, $hasErrors)
Same as getInputHTML, but for Codex.
isDisabled( $alldata)
Test whether this field is supposed to be disabled, based on the values of the other form fields.
validate( $value, $alldata)
Override this function to add specific validation checks on the field input.
escapeLabel( $label)
The keys in the array returned by getOptions() can be either HTML or plain text depending on $this->m...
checkStateRecurse(array $alldata, array $params)
Helper function for isHidden and isDisabled to handle recursive data structures.
getHelpTextHtmlDiv( $helptext, $cssClasses=[])
Generate help text HTML in div format.
getVForm( $value)
Get the complete field for the input, including help text, labels, and whatever.
getHelpTextHtmlTable( $helptext)
Generate help text HTML in table format.
static formatErrors( $errors)
Formats one or more errors as accepted by field validation-callback.
setShowEmptyLabel( $show)
Tell the field whether to generate a separate label element if its label is blank.
getInline( $value)
Get the complete field as an inline element.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
This class is a collection of static functions that serve two purposes:
JSON formatter wrapper class.
Some internal bits split of from Skin.php.
Create PSR-3 logger objects.
The Message class deals with fetching and processing of interface message into a variety of formats.
static newFromSpecifier( $value)
Transform a MessageSpecifier or a primitive value used interchangeably with specifiers (a message key...
parse()
Fully parse the text from wikitext to HTML.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
wasPosted()
Returns true if the present request was reached by a POST operation, false otherwise (GET,...
getCheck( $name)
Return true if the named value is set in this web request's $_GET, $_POST or path router vars,...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Marks HTML that shouldn't be escaped.
Value object representing a message parameter that consists of a list of values.