Posts: 63
Threads: 9
Joined: Nov 2009
Reputation:
0
Has anyone had any success in adding a 'remember me' element to their forms? I'm trying to figure out how I could do this.
I'm trying to emulate the functionality of a commercial hosted form solution that I've used before. In this case what 'remember me' does is automatically populate name, contact details etc. so if the user is submitting multiple forms (with different content) they don't have to keep re-typing their name etc.
Any suggestions are welcome.
Thanks
Martin
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Terrific idea. I can certainly see how this could be helpful.
A little information first. Form integration via the API is handled via sessions (database or PHP). When the user first arrives at the form, it reserves a unique record ID for the form, then keeps track of info as the user progresses through the form. On the final page it submits the content for that unique ID and empties sessions.
So at that point, all data is emptied. If they return to the form at that point, a new submission ID is reserved and they start anew. The trick will be to circumvent this and tell it to remember certain field values.
One hack solution would be to do this: on the final page, right before emptying sessions, store the fields you want in a temporary array. Then empty sessions (ft_api_clear_form_sessions()). Then, store the fields back in the $_SESSION var. Finally, on the first page of your form, after the ft_api_init_form_page() call, check the return value to see if $fields contains empty values for some of the form fields (e.g. the required ones). If it's empty, stick the values from $_SESSION back into that var.
Hack? Yup.
I'll put this down as a feature request. It would nice to have this as a built-in option.
- Ben
Posts: 63
Threads: 9
Joined: Nov 2009
Reputation:
0
Thanks Ben. I was originally thinking that I might be able to achieve this using a cookie but your suggestion seems cleaner.
I'll have a crack at this and see how I go!