17 parent::__construct( $params );
19 if ( !in_array(
'other', $this->mOptions,
true ) ) {
21 $params[
'other'] ??
wfMessage(
'htmlform-selectorother-other' )->text();
30 if ( $value !==
false ) {
31 $value = strval( $value );
32 $valInSelect = in_array(
37 $selected = $valInSelect ? $value :
'other';
39 $select =
new XmlSelect( $this->mName, $this->mID, $selected );
42 $select->setAttribute(
'class',
'mw-htmlform-select-or-other' );
44 $tbAttribs = [
'id' => $this->mID .
'-other',
'size' => $this->
getSize() ];
46 if ( !empty( $this->mParams[
'disabled'] ) ) {
47 $select->setAttribute(
'disabled',
'disabled' );
48 $tbAttribs[
'disabled'] =
'disabled';
51 if ( isset( $this->mParams[
'tabindex'] ) ) {
52 $select->setAttribute(
'tabindex', $this->mParams[
'tabindex'] );
53 $tbAttribs[
'tabindex'] = $this->mParams[
'tabindex'];
56 $select = $select->getHTML();
58 if ( isset( $this->mParams[
'maxlength'] ) ) {
59 $tbAttribs[
'maxlength'] = $this->mParams[
'maxlength'];
62 if ( $this->mClass !==
'' ) {
66 $textbox = Html::input( $this->mName .
'-other', $valInSelect ?
'' : $value,
'text', $tbAttribs );
68 return "$select<br />\n$textbox";
76 return [
'mediawiki.widgets.SelectWithInputWidget' ];
80 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.SelectWithInputWidget.styles' );
83 if ( $value !==
false ) {
84 $value = strval( $value );
85 $valInSelect = in_array(
94 'value' => $valInSelect ? $value :
'other',
95 'class' => [
'mw-htmlform-select-or-other' ],
103 $dropdownAttribs += OOUI\Element::configFromHtmlAttributes(
109 'name' => $this->mName .
'-other',
111 'value' => $valInSelect ?
'' : $value,
123 $textAttribs += OOUI\Element::configFromHtmlAttributes(
127 if ( $this->mClass !==
'' ) {
130 if ( $this->mPlaceholder !==
'' ) {
135 if ( isset( $this->mParams[
'disabled' ] ) && $this->mParams[
'disabled' ] ) {
141 'disabled' => $disabled,
142 'textinput' => $textAttribs,
143 'dropdowninput' => $dropdownAttribs,
144 'required' => $this->mParams[
'required' ] ??
false,
159 if ( $request->getCheck( $this->mName ) ) {
160 $val = $request->getText( $this->mName );
162 if ( $val ===
'other' ) {
163 $val = $request->getText( $this->mName .
'-other' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Select dropdown field, with an additional "other" textbox.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
loadDataFromRequest( $request)
shouldInfuseOOUI()
Whether the field should be automatically infused.
getInputWidget( $params)
Stable to override.
__construct( $params)
Stable to call.
getSize()
Stable to override.
Class for generating HTML <select> or <datalist> elements.