Re: Can you serialize a Formbuilder object?
| From: | Andrew Wooldridge | Date: | Mon, 27 Jun 2005 21:13:29 +0000 |
| Subject: | Re: Can you serialize a Formbuilder object? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19786@lists.php.net to get a copy of this message | ||
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.
>>
>> 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.
>>
>>
>