Re: Can you serialize a Formbuilder object?

From: Date: Mon, 27 Jun 2005 20:43:16 +0000
Subject: Re: Can you serialize a Formbuilder object?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19785@lists.php.net to get a copy of this message
On 6/27/05, Andrew Wooldridge <andrew.r.wooldridge@vanderbilt.edu> wrote: > I am working on a multi-page wizard-like form using quickform controller, > with forms build by formbuilder. The benefits to this are easy to see, but > implementation is tricky. Currently stuck when it comes to processing the > forms with the line: > > $page->process(array(&$fb, 'processForm'), false); > > I am currently using serialize() on the formbuilder objects I create, then > adding them to an array of these serialized objects inside the $_SESSION > array. I do this because each page of the controller calls the php script > again and no formbuilder object can be stored in memory. Without the > serialize array, even if passed by reference, they therefore came back from > $_SESSION as __PHP_Incomplete_Class object type. > > When they are unserialized, some of the objects inside this big formbuilder > object are __PHP_Incomplete_Class Object type, although the $fb itself is > now the appropriate DB_DataObject_FormBuilder type. > > Please advise. Has this been tried before with success? Is it > theoretically possible to completely store and faithfully retrieve a > formbuilder object? -A > You shouldn't need to serialize the formbuilder object. The __PHP_Incomplete_Class type happens because the correct PHP files have not yet been required. Just store the object in your session as normal (no serialize) and make sure to require_once('DB/DataObject/FormBuilder.php'); as well as HTML_QuickForm and any elements that are in the form. Yes I know this is somewhat of a pain. This is why it's just easier to re-generate the FormBuilder. -- Justin Patrin

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