HTML_QuickForm

From: Date: Fri, 18 Jan 2002 16:53:31 +0000
Subject: HTML_QuickForm
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3988@lists.php.net to get a copy of this message
I was working with HTML_QuickForm and have made some minor changes. The problem I was having was when calling addElement(). Currently this method returns nothing and there is no reference to the object you have just created since it is appended to the end of the _elements array. I have modified it so that the array addElement() creates holds references to the new element object and this array is returned. Now I can access the object I have just created easily: $select = $form->addElement('select','id',null,'Choose'); $select['object']->load(dbresult); I think users of HTML_QuickForm will find this useful. The other thing I noticed was in HTML_QuickForm/Elements/select.php. When calling fetchRow() from loadDbResult(), it was checking to make sure fetchRow was returning an array. I have changed it so it checks if fetchRow returns a Pear error, then an array. If it is neither, it returns a new pear error. Here are my diffs: Index: QuickForm.php =================================================================== RCS file: /repository/pear/HTML_QuickForm/QuickForm.php,v retrieving revision 1.10 diff -r1.10 QuickForm.php 438d437 < $this->_elements[] = array("label"=>$elementLabel,"object"=>$elementObject); 439a439 > return $this->_elements[] = array("label"=>&$elementLabel,"object"=>&$elementObject); 1108c1108 < ?> \ No newline at end of file --- > ?> [brian@online7] /usr/lib/php/HTML/QuickForm $ cvs diff Elements/select.php Index: Elements/select.php =================================================================== RCS file: /repository/pear/HTML_QuickForm/Elements/select.php,v retrieving revision 1.3 diff -r1.3 select.php 270c270 < if (isset($values)) { --- > if (isset($values)) { 274,276c274,282 < while (is_array($row = $result->fetchRow($fetchMode)) ) { < if ($fetchMode == DB_FETCHMODE_ASSOC) { < $this->addOption($row[$textCol], $row[$valueCol]); --- > while ($row = $result->fetchRow($fetchMode)) { > if (PEAR::isError($row)) { > return $row; > } elseif (is_array($row)) { > if ($fetchMode == DB_FETCHMODE_ASSOC) { > $this->addOption($row[$textCol], $row[$valueCol]); > } else { > $this->addOption($row[0], $row[1]); > } 278c284 < $this->addOption($row[0], $row[1]); --- > return new PEAR_ERROR('Invalid return value from DB_result->fetchRow'); 436c442 < ?> \ No newline at end of file --- > ?>

« previous php.pear.dev (#3988) next »