diff --git a/includes/htmlform/fields/HTMLNamespacesMultiselectField.php b/includes/htmlform/fields/HTMLNamespacesMultiselectField.php index c448f2d6634..bfa58da2bc1 100644 --- a/includes/htmlform/fields/HTMLNamespacesMultiselectField.php +++ b/includes/htmlform/fields/HTMLNamespacesMultiselectField.php @@ -122,6 +122,11 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace { return [ 'mediawiki.widgets.NamespacesMultiselectWidget' ]; } + public function getInputCodex( $value, $hasErrors ) { + $textAreaField = new HTMLTextAreaField( $this->mParams ); + return $textAreaField->getInputCodex( $value, $hasErrors ); + } + } /** @deprecated since 1.42 */ diff --git a/includes/htmlform/fields/HTMLTextAreaField.php b/includes/htmlform/fields/HTMLTextAreaField.php index 8fe565377a9..4287734b99a 100644 --- a/includes/htmlform/fields/HTMLTextAreaField.php +++ b/includes/htmlform/fields/HTMLTextAreaField.php @@ -163,6 +163,60 @@ class HTMLTextAreaField extends HTMLFormField { 'rows' => $this->getRows(), ] + $attribs ); } + + public function getInputCodex( $value, $hasErrors ) { + $textareaClasses = [ 'cdx-text-area__textarea' ]; + if ( $this->mClass !== '' ) { + $textareaClasses[] = $this->mClass; + } + if ( $this->mUseEditFont ) { + $userOptionsLookup = MediaWikiServices::getInstance() + ->getUserOptionsLookup(); + // The following classes can be used here: + // * mw-editfont-monospace + // * mw-editfont-sans-serif + // * mw-editfont-serif + $textareaClasses[] = + 'mw-editfont-' . + $userOptionsLookup->getOption( $this->mParent->getUser(), 'editfont' ); + $this->mParent->getOutput()->addModuleStyles( 'mediawiki.editfont.styles' ); + } + + $textareaAttribs = [ + 'id' => $this->mID, + 'cols' => $this->getCols(), + 'rows' => $this->getRows(), + 'spellcheck' => $this->getSpellCheck(), + 'class' => $textareaClasses + ] + $this->getTooltipAndAccessKey(); + + if ( $this->mPlaceholder !== '' ) { + $textareaAttribs['placeholder'] = $this->mPlaceholder; + } + + $allowedParams = [ + 'maxlength', + 'minlength', + 'tabindex', + 'disabled', + 'readonly', + 'required', + 'autofocus' + ]; + $textareaAttribs += $this->getAttributes( $allowedParams ); + + $textarea = Html::textarea( $this->mName, $value, $textareaAttribs ); + + $wrapperAttribs = [ 'class' => [ 'cdx-text-area' ] ]; + if ( $hasErrors ) { + $wrapperAttribs['class'][] = 'cdx-text-area--status-error'; + } + return Html::rawElement( + 'div', + $wrapperAttribs, + $textarea + ); + } } /** @deprecated since 1.42 */ diff --git a/includes/htmlform/fields/HTMLTitlesMultiselectField.php b/includes/htmlform/fields/HTMLTitlesMultiselectField.php index 9a1be38496b..3cc4e60e91e 100644 --- a/includes/htmlform/fields/HTMLTitlesMultiselectField.php +++ b/includes/htmlform/fields/HTMLTitlesMultiselectField.php @@ -146,6 +146,11 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField { return [ 'mediawiki.widgets.TitlesMultiselectWidget' ]; } + public function getInputCodex( $value, $hasErrors ) { + $textAreaField = new HTMLTextAreaField( $this->mParams ); + return $textAreaField->getInputCodex( $value, $hasErrors ); + } + } /** @deprecated since 1.42 */