Widget: get content from one table, insert to another

So, Im a new face in Yii2 and I am glad Gii exists. Currently I have 3 tables.
Forms with the field: id.
Fields with the fields: Id, Form_id and Question(text).
Replies with the fields: Id and Reply(text).

Forms and Fields have also generated CRUD from Gii and the Id fields have a relationship.
The idea is to send an ID to a widget and create a form with all the Questions that have that ID.
Then, insert each Question Id with the text value from the form to the Replies table

How should I work? Is it a Gii shortcut and work from there by copying the view into the widget??

Short example: we have 2 forms. Form with Id:1 and form with Id:2. We choose Id:2, so the widget gets from the Fields table every row with Id=2 and creates a list with (lets say) 5 Questions with the Id and a textbox to the side. When the submit button is pressed, the Id and the textbox value are inserted as Id and Reply to the Replies table.

Does Replies have no relation to Forms or Fields?

No, the Replies table have no relations but it can be related to Fields by a new field (Id_field) if needed.

Yeah, you must have field_id field in replies table, or else you can’t retrieve the replies to a certain question afterwards.

Well thank you for the suggestion. I just did not mention how I will use the data later for the sake of simplicity. :wink:

You’d better design your database tables with more accuracy before you proceed with coding.

And what you are trying to do seems to have several challenges that are not very easy even for an experienced developer.

  1. You have to handle multiple models in one form.
    Check the following sections of the guide:
    Collecting tabular input
    Getting Data for Multiple Models
  2. You want to create a widget.
    Create a normal page first, then it will be relatively easy to convert it into a widget.

BTW, please read the following wiki. It’s really helpful, IMO.
Guidelines for good schema design