RE: [PEAR] QF validate

From: Date: Mon, 27 Feb 2006 21:29:40 +0000
Subject: RE: [PEAR] QF validate
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23146@lists.php.net to get a copy of this message
As always, thanks for the input. Mark -----Original Message----- From: Justin Patrin [mailto:papercrane@gmail.com] Sent: Friday, February 24, 2006 4:31 PM To: Mark Steudel Cc: pear-general@lists.php.net Subject: Re: [PEAR] QF validate On 2/24/06, Mark Steudel <mark@netriver.net> wrote: > Lets say you have the following form: > > $form = new HTML_QuickForm; > > $form->addElement('blah1') > $form->addRule('blah1'); > > $form->addElement('blah2') > $form->addRule('blah2'); > > if ( $form->validate() ) > { > process > } > else > { You could try adding this here: $form->setConstants(array('creditCard' => '')); This way the creditCard field is always empty when you display but when the form is submitted this line isn't called and the creditCard field is allowed to be changed. > $form->display(); > } > > When the user fails validation, the form is redisplayed with the > values in the fields, most of the time this is great. But is it > possible to clear the values for certain elements, say blah2? A real > world example might be the credit card information, lots of forms on > validation errors just clear the cc info and require the user to > retype it in but still retain the shipping and billing address. > Or you could unset() the fields in $_POST that you don't want to show up. However, this has to be done *before* the form is *created* (not displayed) due to how QF works and since you wouldn't know if the form is valid yet this isn't a good solution. I suggest the setConstants solution. -- Justin Patrin -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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