N
N
Nikita Kolosov2013-12-18 11:41:07
Yii
Nikita Kolosov, 2013-12-18 11:41:07

How to create a successor of CFormModel?

In general, there is such a situation.
There is a form in which the user, for example, talks about his pets (for example, cats).
Example:
Enter description
Enter quantity.
After choosing the quantity, N subforms (identical) appear, where the user fills in the same information, for example:
Name
Breed
Color
Weight
After everything is filled in, there is a button "Add photo" which he can press as many times as he wants and add photos.
The question is how to correctly create a CFormModel successor for such a case and how to display it correctly. As far as I understand, a view with a subform will be loaded by AJAX and displayed, but I don’t really understand what to do with PHP, which will process all this (validate, save, etc.).
Or, this option is also possible: the user does not select the quantity, but simply presses the "Add pet" button as many times as he likes, after which the subform is displayed to him. But, again, all this should be saved in one place, and I think that making the form manually, without using CFormModel, is not a very good choice.
I read about Tabular Input in Yii, but I didn't quite understand how to use it.
Thank you all in advance for your replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TekVanDo, 2013-12-18
@TekVanDo

The form model is divided into 2 parts, the 1st static part, the 2nd dynamic part after sending, you check these parts separately. If you need an example, yii user extension comes to mind, dynamic user fields are made in this way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question