MetaCrawler, while everybody strongly refuse to answhere this question? Your link is not “good” for me. While don’t show us this resource on google? I spend many hours on google, but can’t find answere? Just HELP US PLEASE!!!
On which part of above code do you have questions?
It validates BOTH models BEFORE actually saving any of them.
Even when you use transactions - you should validate both models.
Somehow I doubt that you have "spend many hours on google" when you have found nothing that helped you making any progress. When I look in google for "yii2 use transactions" or "yii2 save related models" or "Yii2 save mutliple models" I find hundrets of results… (And by the way: That is the reason nobody is answering - because it is easy to find everywhere)
[EDIT: OH - sorry. I just realized you are not the same person who has started this thread. Anyway - the points I wrote above are all still valid.]
Second, i was not precise enough. If i have classical master/child form, master have many record and you mast have id from master before,how to solve it. I found only one very complicated solution in Yii 1.x! Any comment and sugestion will be wellcomme.
softark, in relational database theorie casical example is invoice and invoice items. How to do it in yii2. Nothing more, nothing less. Dinamic form, or tabular xxxx is not good solution, for my ponint of view!
Basically, you should consider creating ONE ActiveForm which contains a master model and an array of related child models. You might want to use a grid for the child models. That’s OK. Include it in the form.
The main model can be treated easily in the standard way. And the related models can be (and should be) treated using the tabular input approach.
First, you must learn how to handle tabulamr input.
As you may notice, you will need to combine the 2 approaches above mentioned.
Well, frankly saying, it’s not that simple and easy. I may or may not write some example for it, because it will be a help for the community as a whole. But I’m not sure whether I may have time to do it. Hopefully someone else may write a good example.
Please remember, we are all volunteers, not your paid tutors. You can never expect us to answer your particular questions. We may or may not answer your questions. It depends.
If you want a good answer, at least you have to try to write a good question.
If I can’t make master/child form with ActiveRecord as source for both, ActiveFom for master and Gred for child, then Yii2 isn’t useful for me. Tabular input is sado/mazo think not useful for me. I need commotion as Active form!!! ActiveRecord, not array.
"If you want a good answer, at least you have to try to write a good question.", I was asking only basic principles!
"We may or may not answer your questions.", if You choose to work Open Source, it mean You have wish to help people!