PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #2567

custom 'callback' validator doesn't work

Details

Submitted2004-10-19 12:58 UTC
Fromnoel dot dacosta at magharl dot co dot uk
StatusBogus
PackageHTML_QuickForm
PHP Version4.2.2
OSlinux redhat 9
Roadmaps(Not assigned)

Comments

[2004-10-19 12:58 UTC] noel dot dacosta at magharl dot co dot uk

Description:
------------
I've created a custom validator, registered it as a callback and passed an array of options to it. Calling it using normal PHP works fine (as you can see below), like so:

$test = checkEmailExists($options);

However, calling it using the $form->addRule method causes the an error.

Reproduce code:
---------------
# check that the email address is unique
$options['email'] = $_POST['user_email'];
$options['user_object'] = $user->getAttribute('user_object');
$options['db_object'] = $request->getAttribute('db_object');



// register with 'callback' type
$form->registerRule('emailexists', 'callback', 'checkEmailExists');
//$form->addElement('text', 'rUpper_0_25', 'Some (mostly lowercase) text:');
$form->addRule('user_email', 'That email address is already registered to another user', 'emailexists', &$options);

$test = checkEmailExists($options);

Expected result:
----------------
What should happen is that the callback validator returns true or false

Actual result:
--------------
Fatal error: Call to a member function on a non-object in /html//lib/validators.php on line 27