diff --git a/composer.json b/composer.json
index 71fb52d5e..c062dcda0 100644
--- a/composer.json
+++ b/composer.json
@@ -63,7 +63,8 @@
},
"config-plugin": {
"params": "params.php",
- "di": "di.php"
+ "di": "di.php",
+ "widgets-themes": "widgets-themes.php"
}
},
"autoload": {
diff --git a/config/widgets-themes.php b/config/widgets-themes.php
new file mode 100644
index 000000000..f3c21a9c6
--- /dev/null
+++ b/config/widgets-themes.php
@@ -0,0 +1,13 @@
+ [
+ GridView::class => [
+ 'tableClass' => ['table'],
+ ],
+ ],
+];
diff --git a/src/GridView.php b/src/GridView.php
index 53ea4e005..fa4ecd918 100644
--- a/src/GridView.php
+++ b/src/GridView.php
@@ -51,7 +51,7 @@ final class GridView extends BaseListView
private bool $headerTableEnabled = true;
private array $headerRowAttributes = [];
private array $rowAttributes = [];
- private array $tableAttributes = ['class' => 'table'];
+ private array $tableAttributes = [];
public function __construct(
private CurrentRoute $currentRoute,
@@ -257,15 +257,38 @@ public function rowAttributes(array $values): self
}
/**
- * Return new instance with the HTML attributes for the table.
+ * Return new instance with the HTML attributes for the table tag.
*
- * @param array $values Attribute values indexed by attribute names.
+ * @param array $attributes The tag attributes in terms of name-value pairs.
+ */
+ public function tableAttributes(array $attributes): self
+ {
+ $new = clone $this;
+ $new->tableAttributes = $attributes;
+ return $new;
+ }
+
+ /**
+ * Add one or more CSS classes to the table tag.
+ *
+ * @param string|null ...$class One or many CSS classes.
*/
- public function tableAttributes(array $values): self
+ public function addTableClass(?string ...$class): self
{
$new = clone $this;
- $new->tableAttributes = $values;
+ Html::addCssClass($new->tableAttributes, $class);
+ return $new;
+ }
+ /**
+ * Replace current table tag CSS classes with a new set of classes.
+ *
+ * @param string|null ...$class One or many CSS classes.
+ */
+ public function tableClass(?string ...$class): static
+ {
+ $new = clone $this;
+ $new->tableAttributes['class'] = array_filter($class, static fn ($c) => $c !== null);
return $new;
}
diff --git a/tests/Column/ActionColumnTest.php b/tests/Column/ActionColumnTest.php
index 47555fb6e..ff14772b1 100644
--- a/tests/Column/ActionColumnTest.php
+++ b/tests/Column/ActionColumnTest.php
@@ -36,7 +36,7 @@ public function testContent(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -84,7 +84,7 @@ public function testContentAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -133,7 +133,7 @@ public function testCustomButton(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -188,7 +188,7 @@ public function testDataLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -233,7 +233,7 @@ public function testFooterAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -286,7 +286,7 @@ public function testLabel(): void
Assert::equalsWithoutLE(
<<
-
+
test.label |
@@ -331,7 +331,7 @@ public function testLabelWithMbString(): void
Assert::equalsWithoutLE(
<<
-
+
Ενέργειες |
@@ -376,7 +376,7 @@ public function testLabelAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
test.label |
@@ -421,7 +421,7 @@ public function testName(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -466,7 +466,7 @@ public function testNotVisible(): void
Assert::equalsWithoutLE(
<<
-
+
@@ -497,7 +497,7 @@ public function testPrimaryKey(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -550,7 +550,7 @@ public function testRender(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -605,7 +605,7 @@ public function testUrlArguments(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -650,7 +650,7 @@ public function testUrlCreator(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -701,7 +701,7 @@ public function testUrlQueryParameters(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -746,7 +746,7 @@ public function testUrlParamsConfig(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
@@ -791,7 +791,7 @@ public function testVisibleButtonsClosure(): void
Assert::equalsWithoutLE(
<<
-
+
Actions |
diff --git a/tests/Column/CheckboxColumnTest.php b/tests/Column/CheckboxColumnTest.php
index fd14b8561..f9c11fa86 100644
--- a/tests/Column/CheckboxColumnTest.php
+++ b/tests/Column/CheckboxColumnTest.php
@@ -35,7 +35,7 @@ public function testContent(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -84,7 +84,7 @@ public function testContentAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -135,7 +135,7 @@ public function testDataLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -182,7 +182,7 @@ public function testLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -229,7 +229,7 @@ public function testLabelMbString(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -276,7 +276,7 @@ public function testLabelAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -323,7 +323,7 @@ public function testName(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -370,7 +370,7 @@ public function testNotMultiple(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -417,7 +417,7 @@ public function testNotVisible(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -461,7 +461,7 @@ public function testRender(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
diff --git a/tests/Column/DataColumnFilterTest.php b/tests/Column/DataColumnFilterTest.php
index 1a1c6a5e9..5dd4f4cf0 100644
--- a/tests/Column/DataColumnFilterTest.php
+++ b/tests/Column/DataColumnFilterTest.php
@@ -74,7 +74,7 @@ public function testFilter(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -121,7 +121,7 @@ public function testFilterDate(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -173,7 +173,7 @@ public function testFilterDateTime(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -225,7 +225,7 @@ public function testFilterEmail(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -277,7 +277,7 @@ public function testFilterInputAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -333,7 +333,7 @@ public function testFilterMonth(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -385,7 +385,7 @@ public function testFilterNumber(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -432,7 +432,7 @@ public function testFilterPositionFooter(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -497,7 +497,7 @@ public function testFilterPositionHeader(): void
Assert::equalsWithoutLE(
<<
-
+
|
@@ -556,7 +556,7 @@ public function testFilterRange(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -607,7 +607,7 @@ public function testFilterRowAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -666,7 +666,7 @@ public function testFilterSearch(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -713,7 +713,7 @@ public function testFilterSelect(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -771,7 +771,7 @@ public function testFilterTelephone(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -825,7 +825,7 @@ public function testFilterTime(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -879,7 +879,7 @@ public function testFilterUrl(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -933,7 +933,7 @@ public function testFilterWeek(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -987,7 +987,7 @@ public function testFilters(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
diff --git a/tests/Column/DataColumnTest.php b/tests/Column/DataColumnTest.php
index 78659254f..33e5f7af2 100644
--- a/tests/Column/DataColumnTest.php
+++ b/tests/Column/DataColumnTest.php
@@ -34,7 +34,7 @@ public function testContent(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -81,7 +81,7 @@ public function testContentAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -130,7 +130,7 @@ public function testContentAttributesClosure(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -177,7 +177,7 @@ public function testDataLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -220,7 +220,7 @@ public function testLabel(): void
Assert::equalsWithoutLE(
<<
-
+
test.id |
@@ -263,7 +263,7 @@ public function testLabelMbString(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -306,7 +306,7 @@ public function testLabelAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
test.id |
@@ -355,7 +355,7 @@ public function testLinkSorter(): void
Assert::equalsWithoutLE(
<<
-
+
id |
@@ -402,7 +402,7 @@ public function testName(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -445,7 +445,7 @@ public function testNotSorting(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -488,7 +488,7 @@ public function testNotVisible(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -528,7 +528,7 @@ public function testSort(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -571,7 +571,7 @@ public function testValue(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -614,7 +614,7 @@ public function testValueClosure(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
diff --git a/tests/Column/RadioColumnTest.php b/tests/Column/RadioColumnTest.php
index 777a7a7b0..75847ef75 100644
--- a/tests/Column/RadioColumnTest.php
+++ b/tests/Column/RadioColumnTest.php
@@ -35,7 +35,7 @@ public function testContent(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -85,7 +85,7 @@ public function testContentAttributes(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -136,7 +136,7 @@ public function testDataLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -183,7 +183,7 @@ public function testLabel(): void
Assert::equalsWithoutLE(
<<
-
+
Id |
@@ -230,7 +230,7 @@ public function testLabelMbString(): void
Assert::equalsWithoutLE(
<<
-
+