Re: resettings HTML Quickform elemetns
| From: | Justin Patrin | Date: | Tue, 28 Jun 2005 16:44:41 +0000 |
| Subject: | Re: resettings HTML Quickform elemetns | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19807@lists.php.net to get a copy of this message | ||
On 6/28/05, Ian P. Christian <pookey@pookey.co.uk> wrote:
> This seems like a nasty hack:
>
> 1 <?
> 2 require_once 'HTML/QuickForm.php';
> 3
> 4 $form = new HTML_QuickForm();
> 5 $form->addElement('text', 'test','test');
> 6
> 7
> 8 $form->validate();
> 9 $form->display();
> 10
> 11 require_once 'Var_Dump.php';
> 12
> 13 Var_Dump::display($form);
> 14 $form->_submitValues = array();
> 15 foreach($form->_elements as $element) {
> 16 $element->setValue('');
> 17 }
That is, indeed, a hack as you're playing with internal vars. Then
again since the QF devs don't seem to want to add functions to access
these properties...
> 18 $form->validate();
> 19 $form->display();
> 20
> 21 Var_Dump::display($form);
>
> Is there a better way to reset the form completely are re-display it?
>
I would suggest redirecting (to clear POST) and then "re-displaying"
your form. I tend to do a header('Location: ') after every form
submission anyway to make sure that the POST data isn't in the browser
history.
--
Justin Patrin