Skip to content

Commit b31edb0

Browse files
committed
Set answered property automatically on pre-filled forms
1 parent 1f71308 commit b31edb0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/models/QuestionModel.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ export default class QuestionModel {
132132
this.answer = this.answer ? [this.answer] : []
133133
}
134134

135+
// Check if we have an answer already (when we have a pre-filled form)
136+
// and set the answered property accordingly
137+
if (!this.required && typeof options.answer !== 'undefined') {
138+
this.answered = true
139+
} else if (this.answer && (!this.multiple || this.answer.length)) {
140+
this.answered = true
141+
}
142+
135143
this.resetOptions()
136144
}
137145

0 commit comments

Comments
 (0)