Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.4

Request #4988 addRow don't work with incomplete array
Submitted: 2005-08-03 15:41 UTC
From: albsala at gmail dot com Assigned: wiesemann
Status: Closed Package: HTML_Table
PHP Version: 4.3.11 OS: GNU/Linux
Roadmaps: (Not assigned)    

 [2005-08-03 15:41 UTC] albsala at gmail dot com
Description: ------------ If you add an array without all column numbers as a new row, addRow don't work as it should be. //This code: $row = array(1 => "Cell1", 2 => "Cell2", 5 => "Cell5"); $table->addRow($row); //only insert cell 1 and 2. Test script: --------------- //Lines 349-355 (addRow method): for ($counter = 0; $counter < count($contents); $counter++) { if ($type == 'TD') { $this->setCellContents($row, $counter, $contents[$counter]); } elseif ($type == 'TH') { $this->setHeaderContents($row, $counter, $contents[$counter]); } } //should be: foreach ($contents as $col => $content) { if ($type == 'TD') { $this->setCellContents($row, $col, $content); } elseif ($type == 'TH') { $this->setHeaderContents($row, $col, $content); } }


 [2005-10-20 13:51 UTC] post at markwiesemann dot de
I can reproduce this problem with current CVS version and have tested the suggested solution - it works as expected. Here is a patch for Table/Storage.php: I can commit it myself, if you want.
 [2005-10-21 08:02 UTC] wiesemann
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.