Re: Quickform rules & documentation

From: Date: Wed, 21 May 2003 14:58:38 +0000
Subject: Re: Quickform rules & documentation
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5509@lists.php.net to get a copy of this message
<mcarter@quantiv.com> wrote : > Hi, > > Is there any documentation in the works for Quickform. From the examples it > appears more powerful than I currently know. Documentation is on its way. The part about form validation is written but not published yet. I currently have no idea when it will be published. > I'm trying to understand the rules - there looks like a number of possible > options are available. > > However - I have a textarea called 'news_summary' which I've added the rule: > $form->addRule('news_summary', 'Provide more detail for your summary', > 'minlength', '10'); If it's empty, it's not checked. You'll have to add a 'required' rule if you want it to be checked aven if it's empty. Then, your minlength rule will be validated. > When I submit the form this rule doesn't get checked - I assumed by > javascript? Also how does the PHP/server side validation happen? Server side validation is on all the time, you can't change that. Client side validation is activated if you add 'client' as last parameter: $form->addRule('news_summary', 'Provide more detail for your summary', 'minlength', '10', 'client); > I'm not to sure of the architecture needed to use Quickform correctly. I'm > wanting to have a form to be filled in, user submits form, the form gets > validated. If errors - re-display form and show errors, else if form > validates fine redirect off to another page. How should I structure my code > to achieve this process with Quickform? You are free to implement any structure you want. QuickForm provides a validator but it doesn't force you to use it. It is on if you call validate(). If the validator finds errors in your form, it displays the form again with errors highlighted, in case you posted the form to the same page naturally. If your form is ok, you can make a redirection to another page or process the submitted values. You can also use sessions if your forms are multipages. A few examples were posted to the list already (pear-general and pear-dev). Good luck, Bertrand Mansion Mamasam

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