Merge "auth: Follow up on e907d4328dc3e"
[lhc/web/wiklou.git] / includes / htmlform / fields / HTMLCheckMatrix.php
index e5e5cdd..274d2c0 100644 (file)
@@ -9,17 +9,18 @@
  *
  * Options:
  *   - columns
- *     - Required list of columns in the matrix.
+ *     - Required associative array mapping column labels (as HTML) to their tags.
  *   - rows
- *     - Required list of rows in the matrix.
+ *     - Required associative array mapping row labels (as HTML) to their tags.
  *   - force-options-on
- *     - Accepts array of column-row tags to be displayed as enabled but unavailable to change
+ *     - Array of column-row tags to be displayed as enabled but unavailable to change.
  *   - force-options-off
- *     - Accepts array of column-row tags to be displayed as disabled but unavailable to change.
+ *     - Array of column-row tags to be displayed as disabled but unavailable to change.
  *   - tooltips
- *     - Optional array mapping row label to tooltip content
+ *     - Optional associative array mapping row labels to tooltips (as text, will be escaped).
  *   - tooltip-class
  *     - Optional CSS class used on tooltip container span. Defaults to mw-icon-question.
+ *       Not used by OOUI form fields.
  */
 class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
        static private $requiredParams = [
@@ -90,9 +91,10 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                // Build the column headers
                $headerContents = Html::rawElement( 'td', [], "\u{00A0}" );
                foreach ( $columns as $columnLabel => $columnTag ) {
-                       $headerContents .= Html::rawElement( 'td', [], $columnLabel );
+                       $headerContents .= Html::rawElement( 'th', [], $columnLabel );
                }
-               $tableContents .= Html::rawElement( 'tr', [], "\n$headerContents\n" );
+               $thead = Html::rawElement( 'tr', [], "\n$headerContents\n" );
+               $tableContents .= Html::rawElement( 'thead', [], "\n$thead\n" );
 
                $tooltipClass = 'mw-icon-question';
                if ( isset( $this->mParams['tooltip-class'] ) ) {
@@ -158,10 +160,10 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                                'id' => $this->mID,
                                'rows' => $this->mParams['rows'],
                                'columns' => $this->mParams['columns'],
-                               'tooltips' => $this->mParams['tooltips'],
+                               'tooltips' => $this->mParams['tooltips'] ?? [],
                                'forcedOff' => $this->mParams['force-options-off'] ?? [],
                                'forcedOn' => $this->mParams['force-options-on'] ?? [],
-                               'values' => $value
+                               'values' => $value,
                        ] + OOUI\Element::configFromHtmlAttributes( $attribs )
                );
        }