11 parent::__construct( $params );
13 if ( !in_array(
'other', $this->mOptions,
true ) ) {
15 $params[
'other'] ??
wfMessage(
'htmlform-selectorother-other' )->text();
24 if ( $value !==
false ) {
25 $value = strval( $value );
26 $valInSelect = in_array(
31 $selected = $valInSelect ? $value :
'other';
33 $select =
new XmlSelect( $this->mName, $this->mID, $selected );
36 $select->setAttribute(
'class',
'mw-htmlform-select-or-other' );
38 $tbAttribs = [
'id' => $this->mID .
'-other',
'size' => $this->
getSize() ];
40 if ( !empty( $this->mParams[
'disabled'] ) ) {
41 $select->setAttribute(
'disabled',
'disabled' );
42 $tbAttribs[
'disabled'] =
'disabled';
45 if ( isset( $this->mParams[
'tabindex'] ) ) {
46 $select->setAttribute(
'tabindex', $this->mParams[
'tabindex'] );
47 $tbAttribs[
'tabindex'] = $this->mParams[
'tabindex'];
50 $select = $select->getHTML();
52 if ( isset( $this->mParams[
'maxlength'] ) ) {
53 $tbAttribs[
'maxlength'] = $this->mParams[
'maxlength'];
56 if ( $this->mClass !==
'' ) {
60 $textbox = Html::input( $this->mName .
'-other', $valInSelect ?
'' : $value,
'text', $tbAttribs );
62 return "$select<br />\n$textbox";
70 return [
'mediawiki.widgets.SelectWithInputWidget' ];
74 $this->mParent->getOutput()->addModuleStyles(
'mediawiki.widgets.SelectWithInputWidget.styles' );
77 if ( $value !==
false ) {
78 $value = strval( $value );
79 $valInSelect = in_array(
88 'value' => $valInSelect ? $value :
'other',
89 'class' => [
'mw-htmlform-select-or-other' ],
97 $dropdownAttribs += OOUI\Element::configFromHtmlAttributes(
103 'name' => $this->mName .
'-other',
105 'value' => $valInSelect ?
'' : $value,
117 $textAttribs += OOUI\Element::configFromHtmlAttributes(
121 if ( $this->mClass !==
'' ) {
124 if ( $this->mPlaceholder !==
'' ) {
129 if ( isset( $this->mParams[
'disabled' ] ) && $this->mParams[
'disabled' ] ) {
135 'disabled' => $disabled,
136 'textinput' => $textAttribs,
137 'dropdowninput' => $dropdownAttribs,
138 'required' => $this->mParams[
'required' ] ??
false,
153 if ( $request->getCheck( $this->mName ) ) {
154 $val = $request->getText( $this->mName );
156 if ( $val ===
'other' ) {
157 $val = $request->getText( $this->mName .
'-other' );