[development] Temporary form data storage ... and avoiding validation

nan wich nan_wich at bellsouth.net
Wed Aug 11 02:20:33 UTC 2010


Hmm, to me that sounds like a good use of $_SESSION for storage (as in the 
cookie), with the advantage that it would persist across site visits, and it 
only belongs to that user.
 
Nancy




________________________________
From: Jeff Greenberg <jeff at ayendesigns.com>
To: development at drupal.org
Sent: Tue, August 10, 2010 10:12:49 PM
Subject: [development] Temporary form data storage ... and avoiding validation

I'm using a module-generated form in a mode like a shopping cart, where the user 
can add data to it, go to other pages, and come back to it, and the data 
persists.

At first I wasn't submitting the data until it was time to complete the process, 
and so, to persist the data, I was using variable_get/set because without the 
form being submitted, nothing was being persisted in form_state.  However, I've 
since switched to each of the buttons (return to other pages, update form, 
submit) causing a submit, with varying logic based on which button was clicked. 
I discovered (duh!) that variable_set/get was a poor idea, because two users 
online at the same time end up would get each other's persisted data on the 
form.

So, two questions. Is form_state going to persist the user data for me between 
form loads, or is there a better method? And I've run into an interesting 
problem in that the portion of the form with required fields (name, etc) doesn't 
need to be filled in until the user wants to submit, but of course, that ends up 
throwing an error when the form is 'submitted' due to one of the other buttons 
being clicked. Is there a way to have those buttons cause a submit, but bypass 
validation?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100810/4f1c1d50/attachment-0001.html 


More information about the development mailing list