Description
Is your feature request related to a problem? Please describe.
Often, later questions in the survey depend on answers from previous questions. Example:
-
What is your favorite food?
<QuestionType.Text>
-
What is your second favorite food?
<QuestionType.Text>
-
Which of your favorite foods is saltier?
<QuestionType.MultipleChoice>
<ChoiceOption answer_1>
<ChoiceOption answer_2>
Describe alternatives you've considered
Currently I have my questions
array as a computed property that can update question choices based on listening to previous answers. This is awkward and not very robust. I have to iterate through the questions
array, find the question with a given id
that I'm looking for, get the answer, do the same thing for the second question, then find the question I want to update, and finally create a new array of ChoiceOption
objects for it. It works but it feels hacky and way more verbose than it should be.
Describe the solution you'd like
There should be some easy way to rely on answers from previous questions. The current system of instantiating a new ChoiceOption
in the component's data
object makes this difficult. After reviewing the source code, I think allowing developers to pass flow-form-question
s directly to the flow-form
component as a slot would allow for the most extensibility and would be most Vue-like. Developers could still use the existing data
-based method of passing questions if they wanted, but an option for something like this would be very powerful and (in my opinion) easier for devs to create different question tracks as well:
<flow-form
// ...your regular flowform options
>
<question
v-model="favoriteFood"
type="Text"
// ...include any other QuestionModel parameters
/>
<question
v-model="secondFavoriteFood"
type="Text"
/>
<question
v-model="saltierFood"
type="MultipleChoice"
:options="{label: favoriteFood}, {label: secondFavoriteFood}"
/>
</flow-form>