I need help learning how to save and restore form data

I need help - right now this is how I feel :frowning:

SavingFormInfo.mp4 (7.3 MB)

Do you want the form data to be saved in real time or by actively submitting?
A few more details would be helpful. :slight_smile:

1 Like

I can add a submit button - this is what the form looks like. Thanks for any help you can provide :smiley:

site is here www.mypizzamaster.com

I see you have already created a topic regarding wapplers state management:

The way I see it, sessions would be the way to go. Session, unlike cookies do not store data on the device locally and they enable a webapplication to store and share variables across multiple pages.
I have to be honest, I have not used the session manager of appconnect yet. But I coded websites which used sessions before and it worked great.

It is really late in my time zone and I need to get some sleep but tomorrow I can check it out for you how this could be achieved by using the session manager.

Nice website by the way :):wink:

1 Like

That would be great - I’m a little overwhelmed with so much new stuff (for me). I’m not in any rush and I hope you found my video funny (because I was trying to be). I really like Wappler and not being able to figure this out is all on me, the program is great!

Thanks for responding and I hope you have a great evening!

1 Like

Do you just one to save the form to a database?

Then just follow the Insert Record tutorial:

If you already got a form you can skip the form creation part

1 Like

Have you viewed this.

2 Likes

Ok as I see it, you have two options.
Upload the form data to a database. How this is done is well described in the tutorial @George linked.
Advantage: Wappler does all the heavy lifting for you. So if you use a server connect form, you just have to name the input fields the same as the post-variables on the server side. And if you create a database for your form, wappler automatically creates all post variables when you add a insert query in your server action.
Disadvantage: Some sort of account management would be needed to enable each user to store his own values. Would be a nice feature though.

The second option:
Use the session storage manager. Just add it in your app structure and create all the variables you need to store each input field. After that you can create a dynamic event (data change or key up e.g.) and as action you set the session value of the input. So each time you type in your input field, your value is being stored in a session. All you have to do now is to create a dynamic attribute of the very same input field and set the value of the session manager. I tried it right now and it works nice!
Advantage: The form data is being stored locally in the browser until the browser is being closed. So no sophisticated account management is needed. And you don’t need to submit the data. It’s being stored in real time.
Disadvantage: I see your form has many input fields so it’s a bit of work to assign the values of each input.
If my explanation is hard to understand, I can try and show it with pictures.

I am still a wappler rookie myself and I hope that this solution is the way, the developers intended it to be. If not, I welcome the guys who have much more experience to correct me.

1 Like

@George, @Hyperbytes and @jowhiskey - thanks for the help. At some point I want to mess around with sessions but I think learning the database is important so my users can have a mechanism to save and recall there work. I think I have seen some videos and info in the Wappler docs that will help with setting up their individual accounts.

The part that I’m not sure about is saving and recalling the form data - I have a fresh cup of coffee next to me so I’ll dig into the references you have pointed me to - thanks and I hope everyone liked my Star Trek video :smiley:

2 Likes

Saving and recalling form data is not that hard once you got the hang of it. I watched the video of @Hyperbytes and imho this is all you need. Thank you for that :slight_smile:
Have a nice day!

2 Likes

I think I’m making progress - set up the DB via phpMyAdmin - Wappler seems to have found it. Hope I’m doing this right…

I would suggest you add a key field, perhaps something like UserID which should be an auto integer number field
So create an integer field, name it, click the A_I check box then in the structure view click on Primary

1 Like

I was going to do that but I have another table that has username and userID - I thought I would (somehow) - use the username in this table to form an association with the username and userID in the other table.

I was thinking once a user logs in I could use that info - likely I need to watch your relational DB video #1 again and watch your 2nd one once you post it… I really have no idea what I’m doing…

Basic rule, every table should have a key field of some type which must be unique. Easiest and most efficient way to do that is as i describe above

2 Likes

If you add a primary key to your database, it enables you to edit records in phpmyadmin so I recommend it. It’s a general guideline to have one unique column in a database.

1 Like

OK, I’ll add it in using phpMyAdmin (I forgot about rule #1) - do I somehow need to add that key field into my wappler form also?

if you open your database connection in server connect and then re-save, wappler will read the new structure

1 Like

OK, that worked :slight_smile:

OK, so I followed along with the direction @George gave me - my database is set up and I did the front end form like in the directions. It seemed to work fine.

So now I need to put the save button on my already existing form (and I’ll call it a win for today)…

Looking at the form that was generated by wappler it looks like I need to add the button and maybe one line of code to save the data on my form.

the two lines I think I need to add to my form are below - is it that easy or do I need to do / should I do something else?

<form is="dmx-serverconnect-form" id="serverconnectform1" method="post" action="dmxConnect/api/Data/insert.php" dmx-generator="bootstrap4" dmx-form-type="horizontal">
<button type="submit" class="btn btn-primary">Save</button>

I reckon you just forgot to change the button type to “submit”. This can be easily done in the properties. You also can assign the button in the form generator and change the button type to submit there.

1 Like