More clarification - Re: [PEAR] Can you serialize a Formbuilder object?

From: Date: Mon, 27 Jun 2005 21:53:55 +0000
Subject: More clarification - Re: [PEAR] Can you serialize a Formbuilder object?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19789@lists.php.net to get a copy of this message
On the first creation of the $fb FormBuilder object, this HTML code is generated by echo print_r($fb); (Notice the array elements are QuickForm_header and QUickForm_hidden rather than __PHP_Incomplete_Class) ---begin snippet--- [_elements] => Array ( [0] => HTML_QuickForm_header Object ( [_text] => MY_TABLE [_label] => [_type] => header [_flagFrozen] => [_persistantFreeze] => [_attributes] => Array ( [name] => ) [_tabOffset] => 0 [_tab] => [_lineEnd] => [_comment] => ) [1] => HTML_QuickForm_hidden Object ( [_label] => [_type] => hidden [_flagFrozen] => [_persistantFreeze] => [_attributes] => Array ( [name] => SYSPROBE [type] => hidden [value] => ) [_tabOffset] => 0 [_tab] => [_lineEnd] => [_comment] => ) --end snippet--- After storing it in $_SESSION and retrieving, it looks like this, unless I require every single file in the HTML/QuickForm directory. > > > ---begin html source------ > [_elements] => Array > ( > [0] => __PHP_Incomplete_Class Object > ( > [__PHP_Incomplete_Class_Name] => > HTML_QuickForm_header > [_text] => MY_TABLE > [_label] => > [_type] => header > [_flagFrozen] => > [_persistantFreeze] => > [_attributes] => Array > ( > [name] => > ) > > [_tabOffset] => 0 > [_tab] => > [_lineEnd] => > > [_comment] => > ) > > [1] => __PHP_Incomplete_Class Object > ( > [__PHP_Incomplete_Class_Name] => > HTML_QuickForm_hidden > [_label] => > [_type] => hidden > [_flagFrozen] => > [_persistantFreeze] => > [_attributes] => Array > ( > [name] => SYSPROBE > [type] => hidden > [value] => > ) > > [_tabOffset] => 0 > [_tab] => > [_lineEnd] => > > [_comment] => > ) > > ---end HTML source------ > > > > If the solution is to simply require everything in that directory then that's fine. I'll try regenerating the form to see if that will include all the necessary supplementary files required. -A >>>> >> >> >>>> Can you tell me more about what you meant by 're-generate the >>>> FormBuilder'? >>> >>> I actually meant regenerate the form. The normal way to use >>> FormBuilder is to regenerate the form on every request, even when a >>> form is submitted. >>> >> >> Would you please tell me how to repopulate the form values previously >> obtained after the new form is regenerated? >> >>>> >>>> >>>> On 6/27/05 3:43 PM, "Justin Patrin" <papercrane@gmail.com> wrote: >>>> >>>>> 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. >>>> >>>> >>> >

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