There is a checkboxlist / radiobuttonlist with response options. The last answer has to be with its own answer, which is written manually.

Example:

enter image description here

The answer option goes into the model and is saved to the general table:

id | id_answer | id_user | 

where id_answer is the ID of the selected answer from the answers table ( id|text_answer ).

id_user is the user ID of the user who owns the answer

Here is the standard checkbox box:

  <?= $form->field($model, 'id_answer')-> checkboxList(Answers::find()->select(['text_answer', 'id_answer ])-> indexBy('id_asnwer')->column(), ?> 

How to supplement it with your own answer?

ps: the user’s own answers are planned to be saved in the answers table, but only prepared in advance for the answer option. (or can it be different?)

  • and how do you want to save your answer without a field in the database for this answer? - MasterAlex
  • @MasterAlex first in the Answers table, there assign it an ID and from there into the general table. Or is it better at all? - Zhi V
  • I mean the message text itself, if you want to save it, then you need to make a field for this, and if you don’t, then just like the other fields by id, and for the text field to output the usual input without any binding to the model: ) - MasterAlex
  • @MasterAlex Well, clearly, but how to do it? For example, so that when a radiolist it is impossible to enter text there, until a jackdaw is placed on it. (as in the picture) I need a form code. I can't find any examples - Zhi V
  • Add a text_answer field to the table. If the person chose "Other", then leave the id_answer null. You can implement logic directly. It is not necessary to fence all ActiveForm'ami and stuff everything into the framework framework. - Vitaly Zaslavsky

0