Re: QuickForm: storing the whole form in a session variable

From: Date: Sun, 06 Nov 2005 17:58:17 +0000
Subject: Re: QuickForm: storing the whole form in a session variable
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21815@lists.php.net to get a copy of this message
On 11/6/05, Mirko Werneke <lists+usenet@haarbrueck.com> wrote: > Hi, > > I'm trying to store a QuickForm-object in a session variable. > > I'm thinking about this: > > if (!isses($_SESSION['form']) { > > $form = new HTML_Quickform('blubb', 'post'); > $form->addElement ... > > $_SESSION['form'] = $form; > > } else { > > $form = $_SESSION['form']; > > } > > if ($form->validate()) { > ... > } > > This would save me the form recreation in the process/validate phase. > Sadly this fails because PHP complains about not defined QuickForm > subclasses while restoring the session. Yes, this is a problem with putting things in the session. You have to define all of the classes that can be saved before using them. If you're using PHP5 you can use __autoload() to make this easier. > > Is there another way to achieve my goals? I have to create my forms of > lots of data that needs to be collected and processed first. So avoiding > the creation of the form in the processing phase would save me a lot of > execution time. > You have another problem as well. QF puts the submitted values in the form object in the constructor so you'd have to fake this as well. -- Justin Patrin

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