Ask a Jedi: Flash Forms and PreserveData

Jimmy has an interesting problem with Flash Forms:

<cfform name="myForm" format="flash" height="476" width="700" skin="haloSilver" timeout="60" preservedata="yes">

I'm using this cfform tag on both the form I'm coming from and the form I'm going to and when I click a submit button to go to the second form and click back the data I entered in the first form is missing. Why isn't it holding the data?

PreserveData simply means, when I reload the form after a submission, preserve the items that were in the form fields. You are not submitting the form, but rather reloading it by hitting the back button. When you hit back, one of two things happen. Either your browser loads the data from cache or the URL is re-downloaded from the server. In either case, the form data you had typed in won't exist anymore.

This is what I suggest if you are building a form that covers multiple steps. Actually I have two suggestions. If you are using Flash Forms, why not considering just having one form - but use tabs or accordions to separate the forms? If you can't do that - you can store the form information for "Form1" into the session scope. Then default the form fields to the session variables if they exist. If you do that, however, you need to make sure you don't let the page get cached. You can do that with the right cfheader tags.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments