*
* 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 = [
// 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'] ) ) {
'id' => $this->mID,
'rows' => $this->mParams['rows'],
'columns' => $this->mParams['columns'],
- 'tooltips' => $this->mParams['tooltips'],
- 'forcedOff' => isset( $this->mParams['force-options-off'] ) ?
- $this->mParams['force-options-off'] : [],
- 'forcedOn' => isset( $this->mParams['force-options-on'] ) ?
- $this->mParams['force-options-on'] : [],
- 'values' => $value
+ 'tooltips' => $this->mParams['tooltips'] ?? [],
+ 'forcedOff' => $this->mParams['force-options-off'] ?? [],
+ 'forcedOn' => $this->mParams['force-options-on'] ?? [],
+ 'values' => $value,
] + OOUI\Element::configFromHtmlAttributes( $attribs )
);
}