Re: HTML_QuickForm questions

From: Date: Sun, 20 Apr 2003 14:25:22 +0000
Subject: Re: HTML_QuickForm questions
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4968@lists.php.net to get a copy of this message
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_example3.php?r=1.2 Jon

« previous php.pear.general (#4968) next »