PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm_Controller » Bug #6110

invalid return value from callback is not handled when validating page

Details

Submitted2005-11-29 17:41 UTC
Fromakutin at symcor dot com
Assignedavb
StatusClosed
PackageHTML_QuickForm_Controller
PHP VersionIrrelevant
OSAny
Roadmaps(Not assigned)

Comments

[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.