RE: [PEAR] HTML_QuickForm questions

From: Date: Thu, 24 Apr 2003 19:58:58 +0000
Subject: RE: [PEAR] HTML_QuickForm questions
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5041@lists.php.net to get a copy of this message
Thank you!! Mac -> -----Mensaje original----- -> De: Jon Wood [mailto:jon@jellybob.co.uk] -> Enviado el: Domingo, 20 de Abril de 2003 11:25 -> Para: ThE PhP_KiD -> CC: PEAR general list -> Asunto: Re: [PEAR] HTML_QuickForm questions -> -> -> 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 -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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