Re: Can you serialize a Formbuilder object?
| From: | Andrew Wooldridge | Date: | Mon, 27 Jun 2005 21:38:41 +0000 |
| Subject: | Re: Can you serialize a Formbuilder object? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19788@lists.php.net to get a copy of this message | ||
On 6/27/05 4:13 PM, "Andrew Wooldridge" <andrew.r.wooldridge@vanderbilt.edu>
wrote:
>
>
>
> On 6/27/05 4:06 PM, "Justin Patrin" <papercrane@gmail.com> wrote:
>
>> On 6/27/05, Andrew Wooldridge <andrew.r.wooldridge@vanderbilt.edu> wrote:
>>> (I'll mirror this exchange on the mailing list afterward)
>>>
>>> I already had those require_once includes you suggested, but without the
>>> 'serialize' line, I continue to get that __PHP_Incomplete_Class rather than
>>> FormBuilder type.
>>
>> Well when I've seen the incomplete class stuff it was because the
>> class wasn't required. Are you absolutely sure that the files are
>> required before you're using the objects?
>>
> I am 99.5% sure, of course I'm testing this right now, as this was your only
> prior experience with this problem.
Result of my test: I had included the line already
>>>> require_once('DB/DataObject/FormBuilder.php');
But I did not call 'require_once' with the others, including all possible
quickform elements are still __PHP_Incomplete_Class typed inside the
formbuilder object :
DB/DataObject/FormBuilder/QuickForm.php
HTML/QuickForm/header.php
HTML/QuickForm/hidden.php
HTML/QuickForm/text.php
Etc....
I require_once'd the /FormBuilder/QuickForm.php and that fixed Incomplete
type error. Might there be a way to avoid requiring every single class used
by quickform?
To illustrate, here's a piece of HTML source generated when I call
echo print_r($fb). If I require_once HTML/QuickForm/header.php this becomes
typed correctly.
Please advise, Justin. Thanks,
Andy
---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------
>>>
>
>
>>> 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.
>>>
>>>
>>