RE: [PEAR] HTML_QuickForm questions
| From: | ThE PhP_KiD | Date: | Sun, 20 Apr 2003 13:59:09 +0000 |
| Subject: | RE: [PEAR] HTML_QuickForm questions | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4972@lists.php.net to get a copy of this message | ||
Thank you, Jhon :-)
Mac
->
-> On Sun, 2003-04-20 at 03:18, ThE PhP_KiD wrote:
-> [...snip...]
-> >
-> > -> * Allows you to create your own validation rules.
-> >
-> > How can I do this ?
-> > ...(I need to validate if a user is or not registred on MySQL
-> database.)
-> >
-> You need to write a function that checks if the user is in the database
-> or not with the following structure:
->
-> function checkUser($element, $value)
-> {
-> // Do the lookup
-> $exists = userExists($value);
->
-> if ($exists) {
-> return true;
-> } else {
-> return false;
-> }
-> }
->
-> Then with your form:
-> $form->registerRule('user_exists', 'function', 'checkUser');
-> $form->setElementRule('user_exists', 'username');
->
-> And go from there.
->
-> For more docs on custom rules take a look at
-> http://cvs.php.net/co.php/pear/HTML_QuickForm/docs/QuickForm_exam
ple3.php?r=1.2
Jon