18 parent::__construct( $params );
20 if ( !in_array(
'other', $this->mOptions,
true ) ) {
22 $params[
'other'] ??
wfMessage(
'htmlform-selectorother-other' )->text();
31 if ( $value !==
false ) {
32 $value = strval( $value );
33 $valInSelect = in_array(
38 $selected = $valInSelect ? $value :
'other';
40 $select =
new XmlSelect( $this->mName, $this->mID, $selected );
43 $select->setAttribute(
'class',
'mw-htmlform-select-or-other' );
45 $tbAttribs = [
'id' => $this->mID .
'-other',
'size' => $this->
getSize() ];
47 if ( !empty( $this->mParams[
'disabled'] ) ) {
48 $select->setAttribute(
'disabled',
'disabled' );
49 $tbAttribs[
'disabled'] =
'disabled';
52 if ( isset( $this->mParams[
'tabindex'] ) ) {
53 $select->setAttribute(
'tabindex', $this->mParams[
'tabindex'] );
54 $tbAttribs[
'tabindex'] = $this->mParams[
'tabindex'];
57 $select = $select->getHTML();
59 if ( isset( $this->mParams[
'maxlength'] ) ) {
60 $tbAttribs[
'maxlength'] = $this->mParams[
'maxlength'];
63 if ( $this->mClass !==
'' ) {
67 $textbox = Html::input( $this->mName .
'-other', $valInSelect ?
'' : $value,
'text', $tbAttribs );
69 return "$select<br />\n$textbox";
77 return [
'mediawiki.widgets.SelectWithInputWidget' ];
81 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.SelectWithInputWidget.styles' );
84 if ( $value !==
false ) {
85 $value = strval( $value );
86 $valInSelect = in_array(
95 'value' => $valInSelect ? $value :
'other',
96 'class' => [
'mw-htmlform-select-or-other' ],
104 $dropdownAttribs += OOUI\Element::configFromHtmlAttributes(
110 'name' => $this->mName .
'-other',
112 'value' => $valInSelect ?
'' : $value,
124 $textAttribs += OOUI\Element::configFromHtmlAttributes(
128 if ( $this->mClass !==
'' ) {
131 if ( $this->mPlaceholder !==
'' ) {
136 if ( isset( $this->mParams[
'disabled' ] ) && $this->mParams[
'disabled' ] ) {
142 'disabled' => $disabled,
143 'textinput' => $textAttribs,
144 'dropdowninput' => $dropdownAttribs,
145 'required' => $this->mParams[
'required' ] ??
false,
160 if ( $request->getCheck( $this->mName ) ) {
161 $val = $request->getText( $this->mName );
163 if ( $val ===
'other' ) {
164 $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.
Class for generating HTML <select> or <datalist> elements.