Home » HTML » HTML_QuickForm » Bug #2567
custom 'callback' validator doesn't work
Details
| Submitted | 2004-10-19 12:58 UTC |
|---|---|
| From | noel dot dacosta at magharl dot co dot uk |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.2.2 |
| OS | linux 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