50 parent::__construct( $config );
52 $this->name = $config[
'name'] ??
null;
53 $this->
id = $config[
'id'] ??
null;
56 $this->rows = $config[
'rows'] ?? [];
57 $this->columns = $config[
'columns'] ?? [];
58 $this->tooltips = $config[
'tooltips'] ?? [];
60 $this->values = $config[
'values'] ?? [];
62 $this->forcedOn = $config[
'forcedOn'] ?? [];
63 $this->forcedOff = $config[
'forcedOff'] ?? [];
66 $table = new \OOUI\Tag(
'table' );
67 $table->addClasses( [
'mw-htmlform-matrix mw-widget-checkMatrixWidget-matrix' ] );
68 $thead = new \OOUI\Tag(
'thead' );
69 $table->appendContent( $thead );
70 $tr = new \OOUI\Tag(
'tr' );
73 $tr->appendContent( $this->
getCellTag(
"\u{00A0}" ) );
74 foreach ( $this->columns as $columnLabel => $columnTag ) {
76 $this->
getCellTag(
new \OOUI\HtmlSnippet( $columnLabel ),
'th' )
79 $thead->appendContent( $tr );
82 $tbody = new \OOUI\Tag(
'tbody' );
83 $table->appendContent( $tbody );
84 foreach ( $this->rows as $rowLabel => $rowTag ) {
85 $tbody->appendContent(
91 $this->addClasses( [
'mw-widget-checkMatrixWidget' ] );
92 $this->appendContent( $table );
104 $row = new \OOUI\Tag(
'tr' );
106 $labelFieldConfig = $tooltip ? [
'help' => $tooltip ] : [];
108 $labelField = new \OOUI\FieldLayout(
111 'label' =>
new \OOUI\HtmlSnippet( $label ),
113 ] + $labelFieldConfig
115 $row->appendContent( $this->
getCellTag( $labelField ) );
118 foreach ( $this->columns as $columnTag ) {
119 $thisTag =
"$columnTag-$tag";
122 $checkbox = new \OOUI\CheckboxInputWidget( [
124 'name' => $this->name ?
"{$this->name}[]" :
null,
125 'id' => $this->
id ?
"{$this->id}-$thisTag" :
null,
130 $row->appendContent( $this->
getCellTag( $checkbox ) );