Re: QFC - should getPage() call HTML_QuickForm_Page::loadValues()?

From: Date: Fri, 25 Feb 2005 14:05:49 +0000
Subject: Re: QFC - should getPage() call HTML_QuickForm_Page::loadValues()?
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17684@lists.php.net to get a copy of this message
some garbage crept into the body of that method. Removing the '<>', it now looks like... ----%<---- /** * Returns a page * * @access public
  * @param  string    Name of a page
  * @return object    HTML_QuickForm_Page     A reference to the page
*/ function &getPage($pageName, $loadValues=false) {
      if (!isset($this->_pages[$pageName])) {
          return PEAR::raiseError('HTML_QuickForm_Controller: Unknown
page "' . $pageName . '"');
      }
      $page =& $this->_pages[$pageName];
      if ($loadValues) {
          $data =& $this->container();
          $page->loadValues($data['values'][$pageName]);
      }
       return $page;
} ----%<---- Matt Flaherty wrote:
I didn't want to lodge this as a feature change request because I'm not sure what people think of it. I have occasion to grab a Page instance from a multi-page form when that instance is not currently displayed. I can grab it using $thatpage =& $thispage->controller->getPage($thatPageName). No mystery there. I might want to perform some task such as to find all checkboxes in a group that were ticked when that Page was submitted. That data is in the container, I'd have thought that would not be a problem. But the values aren't actually loaded into that Page unless I call $thatpage->loadValues($values), where $values is the array of submitted values for that Page which are stored in the container. If I were to call $thatpage->handle('display'), where 'display' is the original action, this would get done for me. I think it would be sensible for getPage() to also do that, since loadValues() seems to be a relatively inexpensive operation. Would there be a compelling reason not to? If so then perhaps a new optional parameter would be appropriate. Here's what this would look like: ----%<---- /** * Returns a page * * @access public
   * @param  string    Name of a page
   * @return object    HTML_QuickForm_Page     A reference to the page
*/ function &getPage($pageName, $loadValues=false) {
       if (!isset($this->_pages[$pageName])) {
           return PEAR::raiseError('HTML_QuickForm_Controller: Unknown page "' . $pageName . '"');
       }
       $page =& $this->_pages[$pageName];
       if ($loadValues) {
           $data =& $this->container();
           $page->loadValues($data['values'][$pageName]);
       }
<>        return $page;
<>    }
----%<---- </Matt>


« previous php.pear.general (#17684) next »