Re: QuickForm: How do I reset a value ?

From: Date: Mon, 13 Feb 2006 22:14:26 +0000
Subject: Re: QuickForm: How do I reset a value ?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22952@lists.php.net to get a copy of this message
On 2/13/06, Alain Williams <addw@phcomp.co.uk> wrote: > I have a simple form, that the user fills in, it passes validation, I put the values in a > database, > I then want to present the same form to the user so that they can fill some more values in, > wash/rince/repeat. > > It all works, except that the second time round the user is presented with the data that they > entered > last time - I want them to see a nice empty form. > > I have tried various solutions: > > After: > $form->validate() > > I go: > > foreach(array('user_name', 'real_name', 'password1', > 'password2') as $field) { > $fp = &$form->getElement($field) > $fp->setValue(''); > } No. Submitted values override setValue and defaults. > The above works for a field that does not have a value submitted as part of a form (eg a > header element). > > I have also tried: > > $val = &$form->getElementValue($field); > $val = ''; > Pretty sure the value is not passed back by ref here, so this won't work. > I could not work out how to make HTML_QuickForm_reset() do anything. > > I am sure that there must be a way of doing it. I don't want to regenerate the entire > form if I can help it. > What you want to do is redirect after a successful form submission. header('Location: YourURLHere'); -- Justin Patrin

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