diff options
author | Func <Funcer@outlook.com> | 2024-12-19 06:00:13 +0800 |
---|---|---|
committer | Func <Funcer@outlook.com> | 2024-12-19 06:03:34 +0800 |
commit | e1b6f72774d98539077e326599d7a9a6c0c2baf2 (patch) | |
tree | 57ebde016cddaefe67a9439ca23ee467b26af204 /includes/htmlform/fields | |
parent | 6c9e4c8bb80f52abb0d96c2b1b2a969d281d366f (diff) | |
download | mediawikicore-e1b6f72774d98539077e326599d7a9a6c0c2baf2.tar.gz mediawikicore-e1b6f72774d98539077e326599d7a9a6c0c2baf2.zip |
HTMLCheckMatrix: Set `vertical-label` instead of overriding `getTableRow`
Change-Id: I36a5cebb63ef047bcf276553a9f18b62c80f8e88
Diffstat (limited to 'includes/htmlform/fields')
-rw-r--r-- | includes/htmlform/fields/HTMLCheckMatrix.php | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/includes/htmlform/fields/HTMLCheckMatrix.php b/includes/htmlform/fields/HTMLCheckMatrix.php index f894f118c3ed..a0bf967dad6d 100644 --- a/includes/htmlform/fields/HTMLCheckMatrix.php +++ b/includes/htmlform/fields/HTMLCheckMatrix.php @@ -6,7 +6,6 @@ use MediaWiki\Html\Html; use MediaWiki\HTMLForm\HTMLFormField; use MediaWiki\HTMLForm\HTMLFormFieldRequiredOptionsException; use MediaWiki\HTMLForm\HTMLNestedFilterable; -use MediaWiki\Json\FormatJson; use MediaWiki\Request\WebRequest; use MediaWiki\Xml\Xml; @@ -56,6 +55,9 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { if ( $missing ) { throw new HTMLFormFieldRequiredOptionsException( $this, $missing ); } + + // The label should always be on a separate line above the options + $params['vertical-label'] = true; parent::__construct( $params ); } @@ -204,50 +206,6 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable { } /** - * Get the complete table row for the input, including help text, - * labels, and whatever. - * We override this function since the label should always be on a separate - * line above the options in the case of a checkbox matrix, i.e. it's always - * a "vertical-label". - * - * @param string|array $value The value to set the input to - * - * @return string Complete HTML table row - */ - public function getTableRow( $value ) { - [ $errors, $errorClass ] = $this->getErrorsAndErrorClass( $value ); - $inputHtml = $this->getInputHTML( $value ); - $fieldType = $this->getClassName(); - $helptext = $this->getHelpTextHtmlTable( $this->getHelpText() ); - $cellAttributes = [ 'colspan' => 2 ]; - - $moreClass = ''; - $moreAttributes = []; - if ( $this->mCondState ) { - $moreAttributes['data-cond-state'] = FormatJson::encode( $this->mCondState ); - $moreClass = implode( ' ', $this->mCondStateClass ); - } - - $label = $this->getLabelHtml( $cellAttributes ); - - $field = Html::rawElement( - 'td', - [ 'class' => 'mw-input' ] + $cellAttributes, - $inputHtml . "\n$errors" - ); - - $html = Html::rawElement( 'tr', - [ 'class' => "mw-htmlform-vertical-label $moreClass" ] + $moreAttributes, - $label ); - $html .= Html::rawElement( 'tr', - [ 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass $moreClass" ] + - $moreAttributes, - $field ); - - return $html . $helptext; - } - - /** * @param WebRequest $request * * @return array |