Store data until the submit button is pressed as temporary

Published 6 months ago by Thameera

I wan't to keep data inserted into form(text) before submit the form but i learned queue in laravel but i did'nt get the idea for that can you suggest the idea or tutorials for that

Best Answer (As Selected By Thameera)
Dry7
Devmaurice

Your question is not clear. But am guessing you want want to manipulate the data before you submit. If that is the case you can use javascript, vuejs can help.

Thameera

but my problem is when user fills a form suddenly machine internet goes off or something happens to machine but user did'nt submit the data so data will be lost so i need to store the data temporally until user press submit how can i do that thorough laravel or should i learn about local storage API

Dry7
Dry7
6 months ago (152,030 XP)
santhusurya

@Thameera As the form filled data is to be stored at client machine until the user press submit button, you have to make use of HTML5 Web Storage.

Please refer to this page HTML5 Web Storage for more details & few examples.

HTML5 Web Storage is the Best approach to store form data temporarily(permanently until next action/form submission) & under any kind of situations when the user couldn't submit the form.

You can easily retrieve form data from HTML5 Web Storage & make a proper form submit whenever it is possible.

biishmar

@Thameera

  • Using ajax u can send data to back end and save it inside session whenever user leave the specific input using blur function in jquery..

  • In the same way, save it inside local storage through javascript.

rsvb
rsvb
6 months ago (7,350 XP)

after leave field, save the field in the database.

Thameera

@rsvb can you pls explain this

rsvb
rsvb
6 months ago (7,350 XP)

when you type in name, you go to next field address, so you leave field name. then you can save field name in the database, and you must do it after every field. You do not save the form fields on click submit, but after leave field.

<script>
function myFunction() {


}
</script>
</head>
<body>

Enter your name: <input type="text" id="fname" onblur="myFunction()">


rsvb
rsvb
6 months ago (7,350 XP)

To store in database you need jquery.

Cronix
Cronix
6 months ago (786,650 XP)

@rsvb Saving per field via ajax on blur opens a lot of additional problems and complexities. If you do that, now you have to create additional routes for each individual input to store the data, so that each field can be validated independently instead of the whole form at once. Now what about fields that depend on other fields in validation rules (like password with password_confirm)? What if they filled out password_confirm before password? Think of a form that has 10-15 fields using complex validation rules. This would just be a pile of a big mess. Saving the data using localstorage in js is the way to go. Everything gets submitted at once, the way it should be and is much simpler. You're also hitting laravel each time you save a field, and also hitting the database. That places an unnecessary additional load on the server. It might not be a big deal on some personal project, but it would if you have 10,000 users using it.

rsvb
rsvb
6 months ago (7,350 XP)

I'm used to a pile of a mess when it goes about internet and js and data jajaja.

Please sign in or create an account to participate in this conversation.