Answer the question
In order to leave comments, you need to log in
How to save each form field to a separate table row?
There is a form consisting of several tables/models - a questionnaire.
The number of fields in the questionnaire is not constant, which does not allow the usual saving in the database. (Fields can be added / removed + can differ according to several criteria)
I came to the conclusion that you can save to a separate table where each line = form field.
How can you pull off such a trick? Exactly how to store each form field as a separate record in a table.
You can use the example of the default feedback form or any other (I imagine the structure of the table itself, but I can’t catch up with how to turn such a save)
Answer the question
In order to leave comments, you need to log in
The number of fields in the questionnaire is not constant
there is such a module https://github.com/ElisDN/yii2-composite-form
I never used it live, but I used its principle when you create, roughly speaking, a container form and inject your forms into it, depending on your scenario, in the container form, you override the two methods load and validate, in which you load and validate the data of internal forms, and in the controller, after successful validation, save your data to the database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question