NetTalk Central

Author Topic: In Memory Forms  (Read 6302 times)

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
In Memory Forms
« on: January 05, 2008, 05:22:03 AM »
Hi All,

I am working on a project where we have a NetTalk site that works beautifully, in which we have a special form created for capturing system settings (i.e. site name, port to use, plus other system wide settings), and we are storing these settings in an XML file (using XFiles) in the app folder.

Everything seems to work sweet.  We can call the admin form for the first time (http://mysite.com/admin) and fill out the details, and the 'Save' button saves the settings and goes back to the main index all OK.

The problem is that when I call the admin form again later, the fields are not pre-filled with the current memory contents.  All the fields in question are just Global variables. (*gasp*), and the form properties has been changed to 'Memory' rather than 'File'.

Is there a way I can get this procedure to auto fill the fields with the current global variables when the form is called?

Thanks,
Devan

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: In Memory Forms
« Reply #1 on: January 06, 2008, 10:58:16 AM »
Is there a way I can get this procedure to auto fill the fields with the current global variables when the form is called?

Hello Devan,

have you already tried to use SessionVariables instead of Global Variables?

You can set and get with the desired values, like p_web.SetSessionValue('name_of_your_var', 'value')


See also:
http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=269

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: In Memory Forms
« Reply #2 on: January 06, 2008, 03:20:04 PM »
Hi Wolfgang,

Thanks for your reply.  I suppose I could use session variables here, but I was hoping that the standard NetWebForm template would do all the hard work for me when I specified 'memory' as the 'Form Source'.

I presume that it is not working because the template is looking for local or threaded variables, whereas I am trying to set system wide global variables??

PS: I am just being lazy here - not looking forward to setting/saving 20 odd session variables for this form!  :)

Cheers,
Devan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: In Memory Forms
« Reply #3 on: January 07, 2008, 03:06:43 AM »
Hi Devan,

"Memory" in the context of a form refers to "Session Variables", not "Global Variables".

This is because Globals are not "user specific" whereas session variables are.

So what you need to do, on entry, is set the session variables, then when the user clicks on "save" copy them back. Tough I know <g> but the right way to do this.

Cheers
Bruce

CyberFerret

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: In Memory Forms
« Reply #4 on: January 07, 2008, 06:52:53 AM »
I was walking through the code on the Form, and I noticed a routine 'StoreMem' that assigned all the non file fields to session variables within the template, so I just placed the line "Do StoreMem" at the top of the process code for the form, and it seems to WORK!!

It can't be that easy, can it?  I always get paranoid when things look too easy!!

Cheers,
Devan
« Last Edit: January 07, 2008, 06:54:55 AM by CyberFerret »