I am creating a project which is similar to online exam system where teachers create questions and answer type like input or radio button etc. I save those records in database and user logs in and see the form accordingly with appropriate input types.
How can i create those fields on the user form? My database is very simple like below
Questions information
id id
teacher_id user_id
subject_id question_id
question answer
input_type
is_required
So i am stuck with a problem that how could i create those fields on the user view file? Should i only create one instance of information model and prints the fields with array? or should i create different instance of information model like below
foreach($modelInformation as $i=>$modelInformation){
echo $form->field($modelInformation, "[{$i}]answer")->textInput();
}
Something like this? or there is some easy way to do this? I am confused because i am not sure how can i give validation if i go this way? Because some of the question can be optional and others are must to answer. If there are any example projects available for similar scenario than point it to me and i will work the rest. Thank you