diff --git a/webfiori/ui/HTMLTable.php b/webfiori/ui/HTMLTable.php
index 97b6e81..74e6386 100644
--- a/webfiori/ui/HTMLTable.php
+++ b/webfiori/ui/HTMLTable.php
@@ -159,7 +159,7 @@ public function getValue(int $rowIndex, int $colIndex) {
if ($cell != null) {
$ch = $cell->getChild(0);
- if ($ch->getName() == '#TEXT') {
+ if ($ch->getNodeName() == '#TEXT') {
return $ch->getText();
}
@@ -170,6 +170,8 @@ public function getValue(int $rowIndex, int $colIndex) {
/**
* Removes a column from the table given column index.
*
+ * Note that if the table has one column, the method will not remove it.
+ *
* @param int $colIndex The index of the column.
*
* @return array The method will return an array that holds objects that
@@ -179,10 +181,11 @@ public function getValue(int $rowIndex, int $colIndex) {
public function removeCol(int $colIndex) : array {
$colCells = [];
- if ($colIndex < $this->cols()) {
+ if ($colIndex < $this->cols() && $this->cols() > 1) {
foreach ($this as $row) {
$colCells[] = $row->children()->remove($colIndex);
}
+ $this->cols--;
}
return $colCells;
@@ -190,6 +193,8 @@ public function removeCol(int $colIndex) : array {
/**
* Removes a row given its index.
*
+ * Note that if the table has only one row, the method will not remove it.
+ *
* @param int $rowIndex The index of the row.
*
* @return TableRow|null If the row is removed, the method will return
@@ -197,7 +202,15 @@ public function removeCol(int $colIndex) : array {
* will return null.
*/
public function removeRow(int $rowIndex) {
- return $this->removeChild($rowIndex);
+ if ($this->rows() > 1) {
+ $row = $this->removeChild($rowIndex);
+
+ if ($row !== null) {
+ $this->rows--;
+ }
+
+ return $row;
+ }
}
/**
* Returns number of rows in the table.