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

Bug #6110 invalid return value from callback is not handled when validating page
Submitted: 2005-11-29 17:41 UTC
From: akutin at symcor dot com Assigned: avb
Status: Closed Package: HTML_QuickForm_Controller
PHP Version: Irrelevant OS: Any
Roadmaps: (Not assigned)    
Subscription  


 [2005-11-29 17:41 UTC] akutin at symcor dot com
Description: ------------ If you add a form rule to a page and your callback function returns something but expected values true or array, the page validates successfully. Test script: --------------- class XPage extends HTML_QuickForm_Page { function buildForm() { $this->addElement( 'text', 'Test', 'Test'); $this->addFormRule( array( $this, 'checkIT')); // other elements } function checkIT( $fields) { // returns invalid value 'false' if Test is empty return strlen( $fields['Test']) != 0; } } in jump, back, next, direct, submit actions instead of $data['valid'][$pageName] = $page->validate(); should be if( PEAR::isError( $valid = $page->validate())) { return $valid; } $data['valid'][$pageName] = $valid; Expected result: ---------------- page does not validate, $controller->run() returns PEAR_Error. Actual result: -------------- the page is considered to be valid, $controller->run() returns true.

Comments

 [2006-02-26 18:31 UTC] avb
Yes, the check for PEAR_Error is missing. Will be added.
 [2006-05-31 08:59 UTC] avb (Alexey Borzov)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net 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. Also added @throws PEAR_Error to several methods' docblocks.