Create an option set for the types (multiple choice / single choice / text / others)
I’d create a database type called ‘form_questions’ with a ‘type’ field that holds a value from the option set.
Then you allow the user to create these questions and assign a type to each of them.
While rendering the user’s custom question, create an RG of the relevant questions and for each questions, display the response fields conditionally based on the type.
Maybe have ‘answer’ as another data type that has a field for all these types of answers, and only the relevant field gets updated when you create an answer, depending on the question’s type.
Plus the answer could also have a field for ‘type’ which uses the same option set to populate. This might help while conditionally rendering existing answers that might have been created.
Just wanting to check this option set method can only be used for prepolulated choices, that I have already setup in the backend.
If the end user wants to have a custom drop down multiple choice answer to go with a question, then I have to create a table where they can insert their custom choices into. And then display this next to the question.
Dynamic choices can be done with the same setup, just using the Data Types a little differently.
For example, one approach could be storing the choices on the ‘question’ thing as text fields and using the ‘type’ option set to inform the condition to render the choices accordingly.
Thanks again, I think I understand, let me have a go and see if I can do it.
For dynamic choices to work, I have to have a field to filter them in that same datatype table. So choices can be grouped togther before being displayed. Assuming the end user might have have different sets of dynamic choices for different questions.
You can have some redundancy built into your data type since it’s not too complex a use case. So I would even build in 4 such fields into the question data type: ‘choice1’, … , ‘choice4’ - all of type text.
This would be what gets displayed with the question if the question’s type (option set) is ‘multiple-choice’. If it’s not ‘multiple-choice’, these fields can remain empty and won’t be used.