-
Hi there, Just wondering if anyone could help me out in saving incomplete form data to local storage and pre-populating the form based on those local storage values (if they exist - otherwise populate answers as 'blank'). Any help would be appreciated! Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Hi, you could use the If you're setting the questions as components, simply set their v-model to whatever value you have saved in localStorage. Example: <template>
<flow-form
ref="flowform"
v-on:step="onStep"
v-bind:questions="questions"
/>
</template>
<script>
export default {
name: 'example',
components: {
FlowForm
},
data() {
questions: [
new QuestionModel({
id: 'first_name',
tagline: 'Hi! Welcome to our demo survey 😊',
title: 'What is your first name?',
type: QuestionType.Text,
required: true,
placeholder: 'Start typing here...',
answer: localStorage.getItem('first_name')
}),
...
},
onStep() {
localStorage.setItem('first_name', this.questions[0].answer)
},
...
}
</script> |
Beta Was this translation helpful? Give feedback.
Hi,
you could use the
onAnswer
oronStep
events to catch when the user answers a question and then save your wholequestions
array to localStorage (or only the answers so as to not use too much storage space), and then when constructing the array, set theanswer
of theQuestionModel
to your saved answer. This field is currently undocumented but I've opened issue #165 to make sure we document this in the future.If you're setting the questions as components, simply set their v-model to whatever value you have saved in localStorage.
Example: