X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLSelectAndOtherField.php;h=86e8e756558613735ef62d875ed841716ca0b03e;hb=36395150104588f2afea866c330b683e4329fa48;hp=e75c2b2507d2e8a0f08711c67bf8edafa1c5f7e9;hpb=f43fa6f4f0e2cb60b8543daad661b48a3e0653a9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLSelectAndOtherField.php b/includes/htmlform/fields/HTMLSelectAndOtherField.php index e75c2b2507..38b487af10 100644 --- a/includes/htmlform/fields/HTMLSelectAndOtherField.php +++ b/includes/htmlform/fields/HTMLSelectAndOtherField.php @@ -11,7 +11,7 @@ * @todo FIXME: If made 'required', only the text field should be compulsory. */ class HTMLSelectAndOtherField extends HTMLSelectField { - function __construct( $params ) { + public function __construct( $params ) { if ( array_key_exists( 'other', $params ) ) { // Do nothing } elseif ( array_key_exists( 'other-message', $params ) ) { @@ -31,10 +31,9 @@ class HTMLSelectAndOtherField extends HTMLSelectField { $this->mOptions = [ $params['other'] => 'other' ] + $this->mOptions; } $this->mFlatOptions = self::flattenOptions( $this->getOptions() ); - } - function getInputHTML( $value ) { + public function getInputHTML( $value ) { $select = parent::getInputHTML( $value[1] ); $textAttribs = [ @@ -64,8 +63,70 @@ class HTMLSelectAndOtherField extends HTMLSelectField { return "$select
\n$textbox"; } - function getInputOOUI( $value ) { - return false; + protected function getOOUIModules() { + return [ 'mediawiki.widgets.SelectWithInputWidget' ]; + } + + public function getInputOOUI( $value ) { + $this->mParent->getOutput()->addModuleStyles( 'mediawiki.widgets.SelectWithInputWidget.styles' ); + + # TextInput + $textAttribs = [ + 'id' => $this->mID . '-other', + 'name' => $this->mName . '-other', + 'size' => $this->getSize(), + 'class' => [ 'mw-htmlform-select-and-other-field' ], + 'data-id-select' => $this->mID, + 'value' => $value[2], + ]; + + $allowedParams = [ + 'required', + 'autofocus', + 'multiple', + 'disabled', + 'tabindex', + 'maxlength', + ]; + + $textAttribs += OOUI\Element::configFromHtmlAttributes( + $this->getAttributes( $allowedParams ) + ); + + if ( $this->mClass !== '' ) { + $textAttribs['classes'] = [ $this->mClass ]; + } + + # DropdownInput + $dropdownInputAttribs = [ + 'name' => $this->mName, + 'id' => $this->mID, + 'options' => $this->getOptionsOOUI(), + 'value' => $value[1], + ]; + + $allowedParams = [ + 'tabindex', + 'disabled', + ]; + + $dropdownInputAttribs += OOUI\Element::configFromHtmlAttributes( + $this->getAttributes( $allowedParams ) + ); + + if ( $this->mClass !== '' ) { + $dropdownInputAttribs['classes'] = [ $this->mClass ]; + } + + return $this->getInputWidget( [ + 'textinput' => $textAttribs, + 'dropdowninput' => $dropdownInputAttribs, + 'or' => false, + ] ); + } + + public function getInputWidget( $params ) { + return new Mediawiki\Widget\SelectWithInputWidget( $params ); } /** @@ -73,7 +134,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { * * @return array("","